Now that Sitecore 10 is out, I've been having a dig into the new Docker approach that's been released. There are some interesting differences here between Sitecore's official approach and the way the community scripts I'd experimented with worked – and I've learned a few interesting new things as a result of having a read of the examples provided. Here are the things that caught my attention:
There is a list of the official images available, but you can see what gets used when you read the compose scripts that Sitecore provide:
The theory is that we take these base images and then build anything different we need on top of them, using Docker's "layered" approach to image creation. Need a CM instance with a particular tool installed? Then you extend Sitecore's image, by adding the tool's files on top. That way build times are reduced, and adopting new releases from Sitecore is easier when they appear.
(Though remember that you still can't push these to a public registry)
You can have both the default
docker-compose.yml
with its
docker-compose.override.yml
file, or give them whatever name you like and specify the files on the command line when you run compose.
In the override file you specify any of the containers in your main compose file, and change any subset of their properties. That makes it ideal for tweaks from the standard config. So for example, you might specify the Solr container as:
solr: isolation: ${ISOLATION} ports: - "8984:8983" image: ${SITECORE_DOCKER_REGISTRY}sitecore-xp0-solr:${SITECORE_VERSION} volumes: - ${LOCAL_DATA_PATH}\solr:c:\data
and then apply an override to limit its memory use:
solr: mem_limit: 1GB
And the two sets of config data will be merged together when you start your containers.
When you add the "
scale
" property to the definition of a container in your compose file, you're telling Docker how many instances of that need to be started. So you can specify zero if you don't want any of that container to come up.
Plus you can combine this with the override files above, so that the CD container doesn't get run just by adding "scale: 0" to the override definition of the content delivery role.
Though take care with the
depends
settings of other containers. You don't want to end up with a container that never starts because it depends on the startup of another container with
scale:0
...
That looks really helpful for simplifying the initial setup of a development environment under Docker. Running
docker-compose up
can create any images that are missing from the local machine as – which can take a step out of the process.