Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot mix Windows and Linux containers in docker-compose.yml #5872

Closed
KevM opened this issue Apr 12, 2018 · 15 comments
Closed

Cannot mix Windows and Linux containers in docker-compose.yml #5872

KevM opened this issue Apr 12, 2018 · 15 comments

Comments

@KevM
Copy link

KevM commented Apr 12, 2018

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.

@vovimayhem
Copy link

vovimayhem commented Apr 13, 2018

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

@KevM
Copy link
Author

KevM commented Apr 13, 2018

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.

@shin-
Copy link

shin- commented Apr 13, 2018

Based on what I'm seeing here: moby/moby#35303

You might want to try setting the platform explicitly for both services. Let me know if that solves the issue.

@KevM
Copy link
Author

KevM commented Apr 16, 2018

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

@KevM
Copy link
Author

KevM commented May 3, 2018

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

@shin-
Copy link

shin- commented May 24, 2018

Thanks for the follow-up! I'll close this issue as a result.

@shin- shin- closed this as completed May 24, 2018
@SeriousM
Copy link

How can this work? "platform" is an unsupported option in docker-compose version 1.21.1, build 7641a56

@kvpt
Copy link

kvpt commented Jun 21, 2018

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).

@JoseFMP
Copy link

JoseFMP commented Nov 30, 2018

@KevM does this really work?

@Ciantic
Copy link

Ciantic commented Dec 29, 2018

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

@crossan007
Copy link

crossan007 commented Aug 29, 2019

Yep - I'm seeing this as not working on Docker Engine 19.03.1 with a 3.7 compose file

Related: #5985 (comment)

@leonicolas
Copy link

Confirming crossan007 comment, it's not working on Docker Engine 19.03.1 with 3.7 compose file.

@WizX20
Copy link

WizX20 commented Mar 6, 2020

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

@MN-83
Copy link

MN-83 commented Nov 21, 2020

My understanding is that the feature is deprecated since WSL2 ==>docker/for-win#9541

But... it seems to be on the roadmap ==> docker/roadmap#79


I am able to have 2 containers in my docker-compose.yaml

version: '3.8'
services:
    apline:
        image: alpine
        command: >
        sh -c "tail -f /dev/null"
    powershell:
        image: mcr.microsoft.com/powershell:lts-nanoserver-1809
        command: ping localhost -t

I have Docker Engine v19.03.13 with the experimental at true & Experimental Feature (Enable CLI + Cloud exp)

@travis-icorein
Copy link

travis-icorein commented Jul 25, 2021

I have Docker Engine v19.03.13 with the experimental at true & Experimental Feature (Enable CLI + Cloud exp)

Results...

Pulling apline (alpine:)...
latest: Pulling from library/alpine
Digest: sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0
Status: Downloaded newer image for alpine:latest
Pulling powershell (mcr.microsoft.com/powershell:lts-nanoserver-1809)...
lts-nanoserver-1809: Pulling from powershell
29d43e56445c: Pulling fs layer
065d37f0b1ee: Pulling fs layer
3a0e86ce39bd: Pulling fs layer
bca392cadf3f: Waiting
223a764fd139: Waiting
33b66422b22c: Waiting
d9d750b7e830: Waiting
8df264f901db: Waiting
35df8da1e697: Waiting
e2044d8c7c57: Waiting
ERROR: image operating system "windows" cannot be used on this platform

Docker Desktop: 3.5.2 (66501), Linux containers (-SwitchLinuxEngine), Use the WSL 2 based engine checked
Windows 10 Pro: v21H1, build 19043.1110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests