I have been searching for several hours and ran through many -v commands on how to mount or bind the host's docker command inside a container so that the container can have access to the docker command.
But none of this works for my ubuntu container. I have Docker Desktop version 4.30.0 on Windows 11 with WSL 2, and I have tried ubuntu 22.04 and 24.04 container images. Would be helpful if there was actually official documentation somewhere detailing how to connect to the host's docker instance (which I can't find).
Reproduce
docker run -v /usr/local/bin/docker:/usr/bin/docker -it <repo>/<image>
Run docker command docker version and get
bash: docker: command not found
The bound volume when you check /usr/bin/docker is actually just an empty folder.
Description
I have been searching for several hours and ran through many
-v
commands on how to mount or bind the host'sdocker
command inside a container so that the container can have access to the docker command.I have checked this closed issue, but the solution commented on Oct 2, 2019, doesn't work for me: https://github.com/docker/for-win/issues/4642
Searching online, you will find various answers like:
Sources: https://stackoverflow.com/questions/36765138/bind-to-docker-socket-on-windows https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
But none of this works for my
ubuntu
container. I have Docker Desktop version 4.30.0 on Windows 11 with WSL 2, and I have triedubuntu
22.04 and 24.04 container images. Would be helpful if there was actually official documentation somewhere detailing how to connect to the host's docker instance (which I can't find).Reproduce
docker run -v /usr/local/bin/docker:/usr/bin/docker -it <repo>/<image>
docker version
and get/usr/bin/docker
is actually just an empty folder.Expected behavior
Command used to just work in giving access to host's docker command inside docker container, as described in this solution: https://github.com/docker/for-win/issues/4642#issuecomment-537550810
docker version
docker info
Diagnostics ID
7649BA3E-A3D0-45FE-9AF4-FA3C03C9B024/20240515024124
Additional Info
No response