Introduction
Sockguard is a Docker socket proxy that inspects the bodies it proxies, not just the URLs.
A Docker socket proxy that actually inspects what it proxies.
Why Sockguard?
The Docker socket (/var/run/docker.sock) is effectively root access to your host.
Any container with socket access can create privileged containers, mount the host
filesystem, and escape containment entirely.
Existing proxies filter by URL path only. Sockguard goes further:
- Request body inspection —
POST /containers/createbodies are parsed to block privileged containers, host networking, and non-allowlisted bind mounts before Docker sees the request - Owner label isolation — stamp created containers, networks, volumes, and build images with an owner label, auto-filter list/prune, deny cross-owner access
- Per-client ACLs — gate callers by source CIDR and enforce per-client allowlists resolved from calling container labels
- mTLS for remote TCP — non-loopback TCP requires mutual TLS 1.3 by default, plaintext TCP is an explicit legacy opt-in
- Structured audit logging — JSON logs with method, path, decision, matched rule, latency, request ID
- Default-deny — everything blocked unless explicitly allowed
- Tecnativa compatible — drop-in replacement using the same environment variables
Quick Start
services:
sockguard:
image: codeswhat/sockguard:latest
restart: unless-stopped
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- sockguard-socket:/var/run/sockguard
environment:
- SOCKGUARD_LISTEN_SOCKET=/var/run/sockguard/sockguard.sock
- CONTAINERS=1
- IMAGES=1
- EVENTS=1
your-app:
depends_on:
- sockguard
volumes:
- sockguard-socket:/var/run/sockguard:ro
environment:
- DOCKER_HOST=unix:///var/run/sockguard/sockguard.sock
volumes:
sockguard-socket:The published image runs as root inside the container by default so it can open
/var/run/docker.sockon stock Docker hosts withoutuserorgroup_addoverrides. The meaningful hardening levers are the proxy policy,read_only, dropped capabilities,no-new-privileges, and your runtime's seccomp/AppArmor/SELinux defaults.
If you choose TCP instead of a unix socket, Sockguard only allows loopback TCP by default. Non-loopback TCP requires mutual TLS unless you explicitly opt into legacy plaintext mode with
SOCKGUARD_LISTEN_INSECURE_ALLOW_PLAIN_TCP=true.