Description
Mounting /var/run/docker.sock gives processes with socket access a direct connection to the host Docker daemon. Even a read-only socket mount allows API requests that change daemon state.
Potential impact
A compromised service can act with the daemon’s privileges. With a rootful daemon, this can expose other containers and host files.
Remediation
Remove the socket mount from application services. Give only trusted build or administration jobs access to the daemon in an isolated environment. Test those jobs and check for other Docker API connections.
Examples
Replace notareal/image:latest with your image. Keep the 8080:8080 port mapping only if the application needs it.
Before
yaml
version: "3.1"
services:
service1:
container_name: service
image: notareal/image:latest
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8080:8080
After
yaml
version: "3.1"
services:
service1:
container_name: service
image: notareal/image:latest
restart: always
ports:
- 8080:8080