Our previous setup for Sitecore development was a virtual machine, using VirtualBox, with all manually installed packages. With the release of Sitecore Experience Commerce 9 (XC9), we decided to give Docker for Windows a try.
Personally, I have had quite a bit of experience with Docker on Linux and it really improved my development flow for Linux applications. We were expecting and hoping for the same boost with Docker for Windows and Sitecore 9. This article describes the good, the bad and the ugly parts of our experience with Sitecore 9 and Docker for Windows. You can find our XC9 Docker setup here
After quite a setup effort, we managed to get all Sitecore configurations right and are now benefiting from the (obvious) Docker advantages:
- All installation and configuration steps are defined in scripts (DockerFiles and PowerShell scripts). Changes to the installation procedure are now under version control and are easier to review and track. Before, changes were manual actions.
- It is very easy to spin up an environment: type `docker-compose up’ and you have a default XC9 environment running.
- It is also easy to keep different XC9 versions. Previously, we were ‘manually’ holding a folder of virtual machine images with different versions, but this was quite error prone to keep track of. We can now easily build, tag and push a new Docker image and everyone can use it without any difficulty.
- Testing different versions has gotten more straightforward. As versions are well managed and because it's very easy to spin up an environment, we can for example easier perform tests on different versions of XC9.
It takes quite a bit of work to determine the steps required to install Sitecore XC9:
- XC9 requires a XP0 setup, which is more difficult to setup than other configurations.
- The Sitecore Installation Framework (SIF) is hard to use. Not all installation steps with SIF are isolated to one container; some require other (database) containers to be running and thus cannot be carried out at the Docker build stage. In addition, the JSON abstraction layer introduces an extra level of complexity that is difficult to understand, especially when customization is required.
- By default, the XC9 setup uses certificates. This makes the setup rather complex to install and debug; for example, inspection of HTTP traffic between containers is impossible.
- Docker for Windows images are huge. Although Docker images only need to be downloaded once, the initial download takes quite some time and the creation of containers is not as fast as on Linux. This makes the development cycle for creating DockerFiles quite slow.
Docker for Windows is not as reliable as Docker for Linux. We encountered some annoying problems, which include the following:
- Containers cannot reach each other by DNS. Only a hard restart of Docker will help, but this is time consuming. In the end, we worked around this by writing hard-coded DNS entries in the ‘etc/hosts’ file.
- The network adapter cannot be found upon restart of containers, which forces you to create a fresh container and lose all intermediate state. The state is easy to recover, but again it's time consuming.
- There are some long-standing known but unsolved Windows image issues, including:
- PowerShell input is limited to 50 characters; copy-paste doesn't work for longer commands
- Date-time is wrong when starting a Windows Server container, which can for example cause problems with authentication.
- The above problems might have occurred because we were using the Edge release (currently 18.03) of Docker. However, the Stable release, for several clear and less clear reasons, did not work for us.
It's tough to get started with Docker for Sitecore development from scratch. Docker for Windows is certainly not as mature as Linux containers. But the momentum for Sitecore and Docker is gaining traction with the inception of Sitecore repositories for Docker images: https://github.com/Sitecore/docker-images
(based on the https://github.com/sitecoreops/sitecore-images
The Sitecore organization is also starting to see the benefits of Docker. As these repositories have tackled or work around most of ‘the bad’ and ‘the ugly’ for you, it should be possible to get your Dockerized Sitecore environment up and running quickly and profit from ‘the good’.