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

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)

2 Likes

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

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
}

This would be really useful. I work with both Windows and Linux containers. I am constantly forgetting to switch to the correct mode, scratching my head when I get an error, and then remembering to switch. It would be nice if the dockerfile could define the mode it requires and everything just works.