简体   繁体   中英

Docker on Windows without Docker Desktop volume mounting

My goal is to use the docker-cli in Windows (docker.exe), but using Linux containers, without the installation of Docker Desktop. I mainly followed these instructions to install Ubuntu 20.04-LTS using WSL2 and prepare everything that dockerd is running inside this instance. ( https://dev.to/_nicolas_louis_/how-to-run-docker-on-windows-without-docker-desktop-hik )

I currently start dockerd with "-H tcp://127.0.0.1" and it does work, I can pull images, run containers, build images etc. from a Windows terminal, my environment contains DOCKER_HOST=tcp://127.0.0.1:2375

What does not work is binding or mounting volumes to local directories, which used to work, when Docker Desktop was installed.

For example trying to run jboss/keycloak mounting /opt/jboss/keycloak/standalone/data to some local path gives me:

docker: Error response from daemon: invalid mode: /opt/jboss/keycloak/standalone/data

which - again - used to work with Docker Desktop, so I do not assume an error in my call.

Can anyone help me getting this to work?

Your docker daemon is running in WSL and you are just connecting to it with de docker command on Windows.

This means that every docker command is actually executed on the WSL subsystem and paths should be specified accordingly.

In particular you should specify paths in WSL, usually your C:/ drive is mounted in WSL under \mnt\c .

I would suggest trying to modifying your run command with those paths, so something like:

docker run -v C:\test\folder:/opt/jboss/keycloak/standalone/data ...

Would become:

docker run -v /mnt/c/test/folder:/opt/jboss/keycloak/standalone/data ...

Make sure you pay attention to the slashes: in WSL you need a foreward slash ( / ) whereas windows does not really care.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM