How to secure a Docker host
An exposed Docker daemon is root for anyone who reaches it, and unpatched images carry known CVEs. These steps cover the basics that matter most.
Steps
- Never expose the daemon on TCP (2375/2376) to the network; use the local socket. If you must use TCP, require TLS client certs.
- Run containers as a non-root user, read-only where possible, and drop capabilities: --cap-drop ALL --read-only.
- Set memory and CPU limits so one container can't starve the host.
- Scan images for vulnerabilities (Trivy) and rebuild from updated bases regularly.
How to verify
- ss -tlnp | grep 2375 should return nothing.
- docker inspect a container and confirm it isn't running as root or privileged.
FAQ
- Is the Docker socket dangerous to mount?
- Yes — mounting /var/run/docker.sock into a container gives it control of the host. Avoid it unless absolutely necessary.
Have SkyShield check this for you
SkyShield finds this across every server and cloud account and shows the fix in plain words. Free for one server, then from $49 per server a month. Start free.