Attempting to mix windows and linux containers in a single docker-compose.yml
does not work.
With the release of compose 1.21.0 I was expecting to be able to mix windows and linux containers.
Windows 10 Version 1709 (OS Build 16299.371)
Docker Engine: 18.04.0-ce-win62 (17151)
Machine: 0.14.0
Compose: 1.21.0
Output of "docker-compose config"
services:
mssql:
image: microsoft/windowsservercore
nginx:
image: nginx-alpine
platform: linux
version: '2.4'
docker-compose up
Creating network "test_default" with the default driver
Pulling mssql (microsoft/windowsservercore:)...
latest: Pulling from microsoft/windowsservercore
ERROR: cannot download image with operating system "windows" when requesting "linux"
Containers to be started.
OS version / distribution, docker-compose
install method, etc.
Using Edge install of Docker for Windows.
@KevM Is that possible? AFAIK you can't run windows & linux containers on the same machine at the same time... The closest use case to what you want to do is when deploying to a swarm having linux and windows nodes, using a compose file...
But if by some case I'm not up to date about Docker 4 Windows capabilities... please correct me if I'm wrong!
Is that possible? AFAIK you can't run windows & linux containers on the same machine at the same time
It is a great question. I don't see this limitation documented anywhere. The FAQ states:
Does Docker run on Linux, macOS, and Windows?
You can run both Linux and Windows programs and excutables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64).
Is the --platform
command line switch there to discriminate which image to pull from the registry? I was under the assumption that it was there to do that and target the correct Docker environment.
Based on what I'm seeing here: https://github.com/moby/moby/issues/35303
You might want to try setting the platform
explicitly for both services. Let me know if that solves the issue.
@shin- Thanks for the assistance.
Added the platform entry for the windows service:
services:
mssql:
image: microsoft/windowsservercore
platform: windows
nginx:
image: nginx-alpine
platform: linux
version: '2.4'
Still failing with a slightly different error message:
> docker-compose up
Creating network "test_default" with the default driver
Pulling mssql (microsoft/windowsservercore:)...
ERROR: invalid platform: invalid platform os "windows"
Note: I do have an environment variable set DOCKER_DEFAULT_PLATFORM=linux
. It does not seem to matter if I change it to be windows
. I still get the same error.
Good news! After updating to Windows 10 1803 17134.1 the following compose file is working:
version: '2.4'
services:
mssql:
image: microsoft/windowsservercore
platform: windows
nginx:
image: nginx
platform: linux
Thanks for the follow-up! I'll close this issue as a result.
How can this work? "platform" is an unsupported option in docker-compose version 1.21.1, build 7641a569
@KevM does this really work?
This should be re-opened, since 3.x does not yet implement it.
Yep - I'm seeing this as not working on Docker Engine 19.03.1 with a 3.7 compose file
Related: https://github.com/docker/compose/pull/5985#issuecomment-526349087
Confirming crossan007 comment, it's not working on Docker Engine 19.03.1 with 3.7 compose file.
Confirming not working with:
Most helpful comment
This should be re-opened, since 3.x does not yet implement it.