37

I inherited a Windows Server Core machine, and I want to run linux-based containers in docker on that machine. It is currently set up to run windows-based containers, so I want to switch to running linux containers.

When I try to use a linux-based image, I get this error:

PS C:\Program Files\Docker> docker pull my-linux-based-image
Pulling from my-linux-based-image
image operating system "linux" cannot be used on this platform

On my Windows desktop machine, I'd use the Docker Desktop context menu from the system tray to switch between linux and windows containers, but that's not available in Windows Core. Can I make this switch from the command line?

I see the suggestion to use DockerCli.exe but I don't have this installed, even after making sure I installed the latest docker package. Is there a separate cli-related package I need?

Here's the version info for the docker install on my Windows Core machine:

PS C:\Program Files\Docker> docker version
Client: Docker Engine - Enterprise
 Version:           18.09.8
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        90e30bdf98
 Built:             07/16/2019 17:13:22
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Enterprise
 Engine:
  Version:          18.09.8
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.8
  Git commit:       90e30bdf98
  Built:            07/16/2019 17:11:04
  OS/Arch:          windows/amd64
  Experimental:     false
Chris Farmer
  • 24,974
  • 34
  • 121
  • 164
  • https://bcthomas.com/2019/02/getting-started-with-linux-containers-on-windows-server-2019/ maybe helpful. – atline Jul 18 '19 at 05:01

3 Answers3

39

Dockercli -SwitchDaemon option should help here.

$ ./DockerCli.exe
Usage: DockerCli.exe [-SwitchDaemon] [-Version]
-Version: Show the Docker for Windows version information
-SwitchDaemon: Point the Docker CLI to either Linux containers or Windows containers
-SharedDrives: List the shared drives

You can control which engine you want to switch with using option.

-SwitchLinuxEngine
-SwitchWindowsEngine

More info here.

Hope this helps.

Update:

DockerCli.exe can be found in Program Files folder.

In my case it was here /c/Program\ Files/Docker/Docker/DockerCli.exe

mchawre
  • 10,744
  • 4
  • 35
  • 57
  • 1
    Thanks. I don't seem to have DockerCli on this machine. Is that part of a separate docker-related installation? – Chris Farmer Jul 17 '19 at 17:55
  • Updated my answer. – mchawre Jul 18 '19 at 05:32
  • 7
    That exe file still doesn't exist for me. – Chris Farmer Jul 19 '19 at 18:02
  • 1
    Same here, couldn't find that exe, installed with: 1. Install-Module -Name DockerMsftProvider -Force. 2. Install-Package -Name docker -ProviderName DockerMsftProvider -Force – Pixel Nov 13 '19 at 16:23
  • 43
    dockercli.exe is installed only with Docker Desktop for Windows. I am running Docker on Windows Server 2019, and did the two ps commands in the previous comment (and restarted the box), and while that's what installed Docker (per the same commands offered at https://hub.docker.com/editions/enterprise/docker-ee-server-windows), I was left in Windows container mode. So I am seeking the same answer as the OP: how to switch to linux conainer mode, via cmd line, since when Docker is installed this were, there is no status try like with Docker Desktop. – charlie arehart Jan 04 '20 at 05:33
  • Dont do this. It may crash docker – Gilbert Feb 09 '22 at 07:24
  • did you ever find an answer @charliearehart – svict4 Mar 16 '22 at 12:04
6

You have to install Docker Enterprise to be able to switch from Windows to Linux containers. See https://computingforgeeks.com/how-to-run-docker-containers-on-windows-server-2019/ for more info.

Kam Salisbury
  • 69
  • 1
  • 1
  • It's clunky, but this works. "Running Linux Containers on Windows Server 2019" section shows `Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview` - that's the key to getting it working (as of today). – daevski May 08 '20 at 15:22
  • 1
    Is it still the case that one needs to install the preview version? – Danwize Dec 09 '20 at 22:43
5

In powershell I Ran below exact command-

./DockerCli.exe -SwitchDaemon

NOTE- before running the above command move to this path

C:\Program Files\Docker\Docker
Sanoj
  • 959
  • 11
  • 11