Compose: Cannot mix Windows and Linux containers in docker-compose.yml

Created on 12 Apr 2018  路  13Comments  路  Source: docker/compose

Attempting to mix windows and linux containers in a single docker-compose.yml does not work.

Description of the issue

With the release of compose 1.21.0 I was expecting to be able to mix windows and linux containers.

Context information (for bug reports)

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'

Steps to reproduce the issue

  1. Switch to Windows containers
  2. Run docker-compose up

Observed result

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"

Expected result

Containers to be started.

Additional information

OS version / distribution, docker-compose install method, etc.

Using Edge install of Docker for Windows.

grouwindows-client kinquestion

Most helpful comment

This should be re-opened, since 3.x does not yet implement it.

All 13 comments

@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

Struggled on that too, after some research for the moment only the version 2.4 of the schema support it, see this.
Version 3.6 of the schema dont support it, as mentioned in this issue.
Support will likely be added for the 3.7 version (here, and here).

@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:

  • docker-compose.yml file in version 2.4
  • windows 10.0.18363 Build 18363
  • docker desktop 2.2.0.3 (42716), engine 19.03.5
Was this page helpful?
0 / 5 - 0 ratings