docker / docs

Source repo for Docker's Documentation
https://docs.docker.com
Apache License 2.0
4.13k stars 7.12k forks source link

Document special behavior when bind-mounting docker socket? #20143

Open vpsx opened 3 months ago

vpsx commented 3 months ago

Is this a docs issue?

Type of issue

I can't find what I'm looking for

Description

(After much experimentation, it seems to me that) when running Docker Desktop for Linux, and not Engine, the -v flag when passed /var/run/docker.sock for the host machine filepath will mount /var/run/docker.sock from the VM; whereas in all other cases, the host machine filepath is interpreted as a path on... the host machine filesystem.

This is confusing in general, but especially if someone reads somewhere that one can "bind mount the docker socket", observes that there is no /var/run/docker.sock on their host, does docker context list and see that they are talking to /home/xxx/.docker/desktop/docker.sock, and attempts to mount that instead.

Location

https://docs.docker.com

Suggestion

No response

vpsx commented 3 months ago

Maybe one other idea might be to show a warning if the user (1) is using Docker Desktop and (2) tries to bind-mount a file of type socket that has a path other than /var/run/docker.sock, since (as far as I understand/have seen) in general when using DD it is not possible to bind-mount a socket on the host. (That is, you can mount it, but then the socket will subsequently not be able to connect inside the container.) But that is outside the scope of docs.