Can't mount windows path inside a docker container like on the host

48 views Asked by At

If I mount a windows path like C:/ when running a docker container in PowerShell, everything works fine and the windows path is correctly mounted.

 PS C:\Users\rene.link> docker run --rm --mount type=bind,source=C:/,target=/data ubuntu ls data/Windows/System32/cmd.exe
 data/Windows/System32/cmd.exe

Passing the docker.sock to a container also works

 PS C:\Users\rene.link> docker run --rm -v //var/run/docker.sock:/var/run/docker.sock docker:24.0-cli docker run --rm ubuntu echo test
 test

But if I pass the docker.sock to a container so that the docker cli inside the container uses the windows docker host, the windows path mount fails.

PS C:\Users\rene.link> docker run --rm -v //var/run/docker.sock:/var/run/docker.sock docker:24.0-cli docker run --rm --mount type=bind,source=C:/,target=/data ubuntu ls -al data/Windows/System32/cmd.exe
docker: Error response from daemon: invalid mount config for type "bind": invalid mount 
path: 'C:/' mount path must be absolute.
See 'docker run --help'.

So I took a look at the docker context on the windows host

PS C:\Users\rene.link> docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                             KUBERNETES ENDPOINT   ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine
desktop-linux       moby                Docker Desktop                            npipe:////./pipe/dockerDesktopLinuxEngine

Can anyone explain why this doesn't work? There must be a difference between the npipe:////./pipe/docker_engine and the //var/run/docker.sock.

Is there anything I can do so that the linux container that I started, behaves like the docker cli on the host?

0

There are 0 answers