Quick Docker Environment Variable tips when working with Sitecore

Vincent Lui
2 min readAug 17, 2021
Photo by ines mills on Unsplash

ThiMost of us who have been working with Docker for awhile, by now, would understand the purposes of Environment Variables. A really quick example from the Sitecore.Demo.Platform site.

<serverUrl>$(env:COVEO_SERVER_URL)</serverUrl>

Note the environment variable name COVEO_SERVER_URL , which is referenced from the .env file as http://cm .

Using Docker Environment variables simplifies some of the config patches that can be applied in Sitecore. Instead of using Environment Require conditions to distinguish between local development versus other environments (e.g. Test, UAT, PreProduction, Production etc), in many cases, those type of condition checks are no longer required. Normally the following scenarios with the setting values are replaced as part of a Deployment Pipeline to substitute the correct values depending on the environment that it is being deployed to.

<setting name="Some.Setting" value="LocallyUsedValue" env:require="LOCAL" />
<setting name="Some.Setting" value="#{Some.Setting}" env:require="!LOCAL" />

This is the step I am using to replace Docker Environment variables in Azure Pipelines, when the other environments are not setup as Kubernetes Cluster. Pay in particular attention to tokenPrefix and tokenSuffix.

This is especially useful with Sitecore Host. In my case, Sitecore Identity Server. The need to worry about the different types of environments in Sitecore Host is not required using this technique.

For those who are hesitant to transition at least their local development environment to using Docker containers, I hope this small little tip above is a nice compelling reason to join.

--

--

Vincent Lui

Sitecore Technology MVP 2020–2023 | Solution Architect on Sitecore, Akamai, Microsoft Azure | Passionate on DevSecOps Lifecycle @ CPA Australia