Dashboards, update checkers and reverse proxies often ask for /var/run/docker.sock, and guides add :ro to feel better about it. That suffix does not do what it suggests.
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
:ro makes the socket file read-only in the mount, which stops the container from deleting or replacing the file. Talking to a Unix socket is not a write to the file, though. The container can still send any API request through it: create a container, mount the host’s root filesystem, start it. The Docker security docs warn that only trusted users should be allowed to control the daemon.
What does limit it is a socket proxy, a small container that sits between the app and the real socket and only forwards the API calls you allow. A typical setup for a dashboard allows listing containers and nothing else. The app then gets the proxy’s address instead of the socket:
environment:
DOCKER_HOST: tcp://socket-proxy:2375
I would keep that proxy on an internal network shared only with the app, never published on a port. And it is worth asking whether a tool needs the socket at all; plenty of monitoring can be done from the host instead.
A proxy that allows POST requests or container creation gives most of the power back. Check its settings, not just that it is there.
Further reading: Docker Engine security, Protect the Docker daemon socket