Docker Community Forums

Share and learn in the Docker community.

Allow explicit definition of target container type when switching between windows and linux containers

(Rfaller) #1

There is a great possibility to switch between Windows Containers and Linux Containers using the following command:
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

But, it is not possible to explicitly define to switched to Windows or Linux Container. My requirement would be to specify this explicity. One idea is to add additional parameter to define the container type (Windows or Linux).

Background: I would like to embed this command in an automatic process. As it is not possible to find out (using a command tooling) which container type is currently active, it is not possile to say if the switch should actually happen).

(Based on Windows Docker Beta Version 1.13.0-rc4-beta34 (9562), running on Windows 10)

(Tjrobinson82) #2

This would be really useful. It’s been a while - is this possible yet?

(Tjrobinson82) #3

This PowerShell is what I’m using and seems to work:

# Switch to Windows Containers
$dockerInfoJson = & docker info --format '{{json .}}'
$dockerInfo = $dockerInfoJson | ConvertFrom-Json

if ($dockerInfo.OSType -eq 'linux'){
    & 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon