CLI to switch between linux and windows images

I can switch between Linux and Windows images using the docker task tray without issue. My question is in regards to the command line. I’ve read and searched the docs but I don’t think I’m looking for the right thing.

2 Likes
& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon
5 Likes

Hi,

I am having problems with windowsservercore container image not installing.

Set-up: macOS Sierra with Windows Server 2016 TP5 running inside VirtualBox alongside Docker.

Steps taken:

In advance i have successfully run:

Install-WindowsFeature containers
Enable-WindowsOptionalFeature -Online -FeatureName Containers

I have also downloaded docker and dockerd to C:\Program Files\Docker. These are the only two files in the folder.

I have then run docker pull microsoft/windowsservercore

This resulted in a download and a message saying ‘Unknown blob’. I don’t know where it has downloaded to or what to do with this ‘unknown blob’.

How do i now ensure this is installed as the windowsservercore image for docker to use? I have re-started docker and run docker images which shows no installed images in the repository.

I thought this might be to do with a Linux default being in place to tried running:

& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon

Which has resulted in a error message:

& : The term ‘C:\Program Files\docker\DockerCLI.exe’ is not recognised as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again…
ObjectNotFound: (C:\Program Files\docker\DockerCLI.exe:String) [], CommandNotFoundException

I do not have a file called DockerCLI.exe.

Alternatively, i have downloaded the image file ‘WindowsServerCore-10-0-14300-1000.wim’ to C:\Program Files\docker, where i also have the docker and dockerd executables. Can i install this instead? If so, how please?

I do not have a docker icon appearing in my VirtualBox WindowsServer environment so cannot use the switch there.

I have posted a lot about this, for example here StackOverflow post ,and would be grateful for any advice that might help resolve this.

Hi,

I resolved the issue and added the solution to the StackOverflow post mentioned above.

Is it possible to specify the container type? say linux or windows. I am scripting this via a build system which deploys both linux and windows containers depending on my project type.

I took a look at DockerCli, and I’m hoping there’s more interaction possible than what is shown:

$ ./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

Is there any way to identify what type of Daemon is currently running, other then by toggling it? Being able to see the other current operating options would be very helpful, too, when gathering info on failures of containers and tools using them.

Only interacting with Docker for Windows via the task tray is very problematic because we need Docker to be running after rebooting its server. Initially, I was doing this with a scheduled task, but that resulted in the task tray icon not being visible for the Administrator. A colleague showed me how to get the Administrator to log-in automatically at start-up, which resolved the missing task tray icon issue but seems like bad practice.

1 Like

You can control which engine you want to switch to with

-SwitchLinuxEngine
-SwitchWindowsEngine

There’s also these…

-Start
-Stop
-SendDiagnostic
-ResetToDefault
-ResetCredential
-DownloadMobyLogs
-DownloadVpnKitLogs
-MoveVhd
-Mount=
-Unmount=
-Wait=
-SetMemory=
-SetCpus=
-SetDNS=
-SetIP=
-SetDaemonJson=
-SetWindowsDaemonJson=
6 Likes

Where did you get this information from? I can’t find any documentation anywhere and the current ‘help’ command only prints this:

> & 'C:\Program Files\Docker\Docker\DockerCli.exe' -h
Usage: DockerCli.exe [Command]
  -h, --help, -Help: Show the help information for this command

Doesn’t even print the original usage (-Version, -SwitchDaemon, etc)

I don’t even know where to submit a bug report.

5 Likes

I’m looking for this, as well - if anyone could point to the dockercli.exe documentation, I’d really appreciate it!

3 Likes

I also looking for this.

2 Likes

I went looking again and found my own comment in my search… Seems like this is still not resolved. Did you find anymore info? Or even where to properly submit a bug report?

1 Like

Curious where you found this information. I would like to find the bug report submission for DockerCli so we can get this resolved.
I can’t believe this application with a full set of switches/parameters doesn’t have a Usage statement.

1 Like

Hi. This DockerCli.exe looks boring indeed, without --help :frowning:
I also miss a way to know in which mode (linux or windows) the daemon is running. I often end up being in the wrong mode (I have to work with both kinds of containers), and this causes a lot of headache. Being able to display more clearly the current mode (eg. as part of cmdline prompt) would be great!

I don’t have my Windows in front of me, but docker info should show you some info about the kernel and operating system. The kernel and the OS is different in each mode.

Excellent, thanks! It works indeed:
$ docker info | grep -i ostype | awk '{ print $2; }'

I saw a new reply from you in e-mail. I don’t know if you deleted it or it was the spam filter again, but if you want to get the operating system, you can do it without grep too:

docker info --format '{{ .OSType }}'

This works on all platfoms, since everything is done by Docker.

2 Likes

Hi. Seems “Switch to Windows containers…” was disabled? I cant find it running v4.11.0 (83626)

image

Interesting. My Desktop shows that option, but it also shows me that I should update to 4.11.0, when I have already done it and there is nothing in “Software updates”. I run “Reset factorsy data” and nothing changed. “About Docker Desktop” shows that I have the correct version so it is probably a bug in Desktop or it is bsed on the Windows version. I have Windows 11, 21H2 (OS Build 22000.795) What is your version?

I also noticed that I don’t have the “Check for updates” in the menu and you have that but.

update:

I restarted Docker and the “Check for updates” menu appeared and it shows I have the latest version. Have you tried to restart Docker some times?

I have Windows 10 21H2 (19044.1865).

I’ve managed to fixed it by switching to Windows containers in CMD "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine

Then switch back to Linux C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine

And finally restart Docker Desktop

2 Likes

Thanks! I had forgotten about the Go templates… really nice feature.

( and indeed, my post was blocked by the spam filter… )