There are a few exciting developments in Sitecore XP 10. One of them is support for running Sitecore on Docker. Though significant work has been done by community on this before, with Sitecore official support for this, adoption would definitely increase by a large extent.
Sitecore Containers support rapid deployment and more efficient solution and team onboarding with modern Docker and Kubernetes technology. It brings the benefits of containerization technology to Sitecore projects. Key benefits in Sitecore projects:
- Very easy setup – No more installation using SIF (Sitecore Install Framework), SIM (Sitecore Instance Manager), etc. Sitecore provides container images ready to use.
- Run multiple versions – Run multiple Sitecore instances simultaneously without worrying about things like conflicting versions of SQL and Solr. Start and stop entire instances quickly when jumping between projects, making better use of your machine’s resources.
- Simplified onboarding – The developer onboarding process can now be as simple as: install prerequisites, clone your code repository, run docker-compose up
- Environment consistency – Eliminate issues due to environment inconsistencies. No more “works on my machine”. Containerize your build to have complete control of the build environment through DevOps / continuous integration (CI).
- Environment stability -If your local Sitecore instance is corrupted, simply do docker-compose down and docker-compose up.
This is my experience of running Sitecore-xp0 in Docker:
- Set up:
- Install Docker Desktop for Windows. Pre-requisites for installing:
- Hyper V enabled on laptop
- 16 GB RAM
- Admin privilege
- Run Docker Desktop for Windows. You might have to start Docker service first from services.exe
- Switch to Windows Containers. Right click docker in task tray & switch to windows containers
- Test in Powershell. Run command docker version or docker run hello-world.
Once docker is set up, we can start with steps for Sitecore. There are just 4 steps to execute:
- Clone repository from github https://github.com/Sitecore/docker-examples
- Open a PowerShell prompt as admin and navigate to the getting-started folder in the repository. This folder has
- .env file with required variables that will be populated by init.ps1 script.
- init.ps1 script that executes all the pre-requisites
- docker-compose.yml file: this has the containers configuration for Sitecore XP0 topology. As seen in screenshot it has 9 containers configuration that will be created on running step 4.
- Run this command .\init.ps1 -LicenseXmlPath C:\License\license.xml . This will do the following:
- Install SitecoreDockerTools
- Populate the environment file (.env)
- Configure TLS/HTTPS certificates
- Add Windows hosts file entries
- Start Sitecore – Run command docker-compose up –d
- Download all required images from the Sitecore Container Registry
- Create a default network to use
- Create a container for each configured service, and
- Start the containers with their configured entrypoints
Once done successfully, you will see Sitecore running successfully in Docker Dashboard.
Issues encountered by me in running these steps:
- In step 3, you have to provide full path to license.xml file even if it is placed in “getting-started” folder. Else it will give error as:
- In step 3, error in installing mkcert tool.
- Cause: it was not able to access github url to download the exe
- Resolution: downloaded manually & copied it to E:\Projects\docker-examples-develop_11Sep2020_Containers\getting-started\traefik\certs with name mkcert.exe. Then commented the line for downloading it in init.ps1 file.
- After this step 3 completed successfully.
- Step 4: command “docker-compose up -d” The download of images took 2-3 hours & after all downloads completed, threw this error:
- Cause: The default Sitecore container configuration uses specific ports. To avoid any conflicts, we have to ensure that the following ports are not being used by another process: 443, 8079, 8081, 8984, and 14330.
- Resolution: To determine which port is in use I ran following command: netstat -aon | findstr 8984
- To know service name: tasklist | findstr ‘5480’
- Stopped the service mentioned in above image from services.exe
- Repeated this for other ports & closed few more services running on my laptop
- To know service name: tasklist | findstr ‘5480’
- Step 4: command “docker-compose up -d” : container is unhealthy error:
- Cause: Unknown
- Resolution: Taking cue for stack exchange, ran these commands:
- Run docker-compose stop on Powershell.
- Run docker-compose down on Powershell.
- Now run iisreset /stop on Powershell to make sure that the required ports are free.
- Now run docker-compose up on Powershell.
- This time it completed successfully
- Tried to run the site in browser https://xp0cm.localhost/, however it threw 404 error.
- Cause: In Docker desktop, I could see CM container is not running.
Clicked on the container to see the logs. Logs said “Failed to update IIS configuration”.
- Resolution: Ran iisrest /start & ran docker-compose down & docker-compose up again. I also changed docker-compose.yml file to remove xdbAutomation & cortex workers by adding scale: 0 & removing depends on for these services to reduce memory consumption in case that is causing the issue. It worked after few retries of docker-compose down & docker-compose up
- Cause: In Docker desktop, I could see CM container is not running.
- The URL https://xp0cm.localhost/ now showed SItecore welcome page & I was able to log into Sitecore launch pad as well https://xp0cm.localhost/sitecore.
References: https://doc.sitecore.com/developers/100/developer-tools/en/containers-in-sitecore-development.html