Run Sitecore Docker Containers in your Helix Solution using Container Tools in Visual Studio 2019

Dear Sitecorians, I hope you all have a wonderful time πŸ™‚
First of all to all new and old Sitecore MVPs – CONGRATULATIONS!!

Secondly, don’t forget to book for SUGCON Europe 2020.
The agenda looks really interesting,

Today’s post will be about… DOCKERS. The never-ending flow of the wonderful Sitecore Docker Images.
*Guess which session I will be at(in SUGCON Europe 2020), this one of course πŸ™‚

I would like to share with you guys a very cool way of working with Sitecore Docker containers – Using the Docker Compose project(dcproj) together with the “Container” window in Visual Studio, it’s just awesome!!

They all love it, check out Scott Hanselman’s post: Trying out Container Tools in Visual Studio 2019

So what is Docker Compose?

When you want to compose a multi-container solution using Docker Compose, add container orchestration support to your projects. This lets you run and debug a group of containers (a whole solution or group of projects) at the same time if they’re defined in the same docker-compose.yml fil

You can read all about it here, Container Tools in Visual Studio

So first we need to create a new project in our lovely Helix Sandbox Solution, as always we will use the best ever sandbox solution – Helix.Examples. You can find all the work in my fork:

If we were working in Asp.Net Core, then it would be quite easy to create a DockerCompose project(.dcproj):

Unfortunately we are still in Asp.Net Framework 😦
*We can at least find comfort in using the new project type in our projects πŸ˜‰

Instead, we will create the project manually. We will switch to folder view in our solution(no need to use the File Explorer) and navigate to the src folder in folder helix-basic-tds-with-docker-vs2019-project-type. Here we will create a DockerCompose folder. Right click and create the following files:
– docker-compose.dcproj => project
– .env => The environment variables for the docker-compose file
– docker-compose.yml => docker-compose file
– docker-compose.override.yml => docker-compose file

For the docker-compose.dcproj, we will add the following:

<Project Sdk="Microsoft.Docker.Sdk">
  <PropertyGroup Label="Globals">
    <None Include=".env" />
    <None Include="docker-compose.override.yml">
    <None Include="docker-compose.yml" />

At github,

The .env file will be the same as before:
REMOTEDEBUGGER_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Remote Debugger

At github,

For the docker-compose.yml, we will do some minor path changes for the data folder(Located in helix-basic-tds-with-docker-vs2019-project-type/Docker)

version: '2.4'


    image: ${REGISTRY}sitecore-xp-spe-sqldev:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}
      - ..\..\Docker\data\sql:C:\Data
    mem_limit: 2GB
      - "44010:1433"
      ACCEPT_EULA: "Y"

At github,

For the docker-compose.override.yml, just add the version for now:

version: '2.4'

At github,

Next will be to switch back to the “Solution view”(in Visual Studio) and add the new project we created – docker-compose.dcproj.

And voila, we have a Docker Compose project πŸ™‚

One thing is needed before we run the Docker Compose project, we need to execute Set-LicenseEnvironmentVariable.ps1 script in our Docker folder(C:\Projects\Helix.Examples\examples\helix-basic-tds-with-docker-vs2019-project-type\Docker):

.\Set-LicenseEnvironmentVariable.ps1  -Path C:\license\license.xml -PersistForCurrentUser

Finally, set the Docker Compose project as StartUp Project and hit Docker Compose πŸ™‚

To add the Container Window, just do View=> Other Windows=> Containers:

The Container tool is great, you can check Logs, Ports and Files:

And you can open up a Terminal Window to your favorite container, like this:

This is pretty awesome!

There is one thing left and that is to run it in debug mode “directly” when we hit “Docker Compose”. For now, we still have to attach the debugger. Meaning we need to get the IP address from the container and all that annoying stuff. I have been experimenting with adding a Docker file to the BasicCompany.Project.BasicCompany project but still no success… 😦


.... do some stuff

And then in the docker-compose file something like this:

     context: .\..\Project\BasicCompany\website
     dockerfile: .\..\Project\BasicCompany\website\dockerfile


I will keep on trying until I find a solution…
It would be great if you guys could help out!

Fork my fork and start coding πŸ™‚

Think how neat it would be, to just set the Docker Compose project as Startup and hit F5. No more attaching a debugger and all that…

That’s all for now folks πŸ™‚

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.