One of the features when running Docker on Windows is that it’s possible to switch between Linux and Windows containers.
This basically means that it’s possible to run Linux containers on top of the Windows hosts, because the container will run inside a small Linux based Hyper-V Virtual Machine.
The other option is off course to run a Windows containers more or less natively on the Windows host.
Alright lets take a look how we can switch between the different “Operating Systems”…
Switching container OS architecture
First lets look on what OS architecture we are running.
Just run the following command and check what is mentioned at OS/Arch.
PS > docker version
In the example here above, Docker is running Linux containers (Server: –> OS/Arch: –> linux/amd64).
Lets take a look at the images that are already pulled from the Docker Registry.
To show the current Docker images, just run the following command in PowerShell.
PS > docker image
The GUI/clickable way
Switching to Windows containers
The easiest way is to right click on the Docker icon on the taskbar.
And click on Switch to Windows/Linux containers… dd
Note: it could take some time to switch between Windows to Linux containers because it need to spin-up the Linux virtual machine.
Checking OS architecture
Now we have switched over to Windows containers we should see some difference when we run the following command.
PS > docker version
As shown here above, we can see Docker is no longer running on Linux, but is switched over to the Windows mode.
Lets take a look at the Docker images!
PS > docker images
As shown here above, we no longer have any Linux Docker images in the image store, because we have switched over to Windows mode. However the Linux images are still available when switching back to Linux mode.
The CLI way
Switching between Windows and Linux mode can also been done with help of a command line tool.
It’s super easy just open a Windows PowerShell window and execute the following command.
PS > & 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
Once you see a new line Docker has been switched over to Windows/Linux mode.