0

Haven't come across any article that says how to setup Docker in Docker for Windows (native, not WSL). Trying to build a Windows Server Core based image but from within a Windows Server Core Container. Is this possible?

Ashik
  • 317
  • 3
  • 12

3 Answers3

1

So, I took some time to test this out and it turns out that it actually works: Windows container running inside a Windows container

The catch here is that the docker engine on the container needs to be mapped to the docker engine from the underlying container. Here is the docker file I used:

    # escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022

RUN powershell -Command `
        $ErrorActionPreference = 'Stop'; `
        $ProgressPreference = 'SilentlyContinue'; `
        Invoke-WebRequest `
            -Uri https://download.docker.com/win/static/stable/x86_64/docker-20.10.15.zip `
            -OutFile docker.zip; `
        Expand-Archive docker.zip -DestinationPath 'C:\Program Files'; `
        Remove-Item docker.zip -Force `
    && setx /M PATH "%PATH%;C:\Program Files\docker"

Here are the commands I ran:

docker run -i -v \\.\pipe\docker_engine:\\.\pipe\docker_engine inception:v1 powershell

This will open a container interactively. From there, run:

docker run --rm mcr.microsoft.com/windows/servercore:ltsc2022 cmd /c hostname
0

Docker Desktop should be used on Windows 10/11 only. For Server environments, which Windows containers are based on, you should install the Docker/Mirantis engine. However, I'm not entirely sure this would work and even if it does (one can try), it should not be supported.

  • Thank you for your answer. Docker in docker works for Linux, so should it not be available for native Windows Containers also? – Ashik May 20 '22 at 20:30
0

FYI, from @vinicius response you might need to specify --network flag when building the image i.e docker build --network="Default Switch" -t inception:v1 .