Using Docker Compose V2 with Sitecore Docker
There are many utilizing Docker for their local Sitecore development, but required disabling Docker Compose V2 within Docker Desktop as they were receiving the following error:
level=warning msg="network default: network.external.name is deprecated in favor of network.name" not implemented
unknown flag: --d
My colleague Gabe Streza higlights this issue in his post: Docker Compose Failing; ‘unknown flag: –d’ ~ Sitecore Gabe
The challenge is that Docker is moving away from Docker Compose V1 starting June 2023 per the Overview of docker compose CLI where they state:
From the end of June 2023 Compose V1 won’t be supported anymore and will be removed from all Docker Desktop versions.
Make sure you switch to Compose V2 with the
Overview of docker compose CLIdocker compose
CLI plugin or by activating the Use Docker Compose V2 setting in Docker Desktop. For more information, see the Evolution of Compose
Contents
Can We Use Docker Compose V2 for Sitecore Docker?
Yes! You can use Docker Compose V2 for Sitecore Docker. This requires the following:
Enable Docker Compose V2 within Docker Desktop
Go to the Docker Desktop Settings (Gear icon near the “Sign in”) and under general check Use Docker Compose V2 and “Apply & Restart”.
Update Any Calls to Docker Compose
This is what was causing the issues with an unknown flag when using V2 of Docker Compose. When using Docker Compose V2, you need to use commands with a space. Previously, a Docker Compose would use a dash like the following:
docker-compose up -d
However, in Docker Compose V2, it uses a space instead of a dash for commands like the following:
docker compose up -d
This is called out in the Docker documentation where it states:
The new Compose V2, which supports the
compose
command as part of the Docker CLI, is now available.Compose V2 integrates compose functions into the Docker platform, continuing to support most of the previous
Overview of docker compose CLIdocker-compose
features and flags. You can run Compose V2 by replacing the hyphen (-
) with a space, usingdocker compose
, instead ofdocker-compose
.
Update .ps1 References with a Double Slash
An additional item I noticed when switching to Docker Compose V2 is that my CM and CD would not start. In fact, they were failing to find a module named:
C:toolsentrypointsiisDevelopment.ps1
This is because in my docker-compose.override.yml file did not have an escape for the PowerShell tools reference. This may have worked in Docker Compose V1, but in V2 is detected. Changing this for both the CD and CM references in the docker-compose.override.yml file:
entrypoint: powershell -Command "& C:\tools\entrypoints\iis\Development.ps1"
to this, resolves the issue:
entrypoint: powershell -Command "& C:\\tools\\entrypoints\\iis\\Development.ps1"