Secure Docker socket proxy with endpoint-level access control
1.9K
A lightweight, security-focused proxy for the Docker socket. Restrict which Docker API endpoints are accessible to containers, preventing unauthorized access.
Mounting /var/run/docker.sock into containers (for Traefik, Portainer, etc.) gives full Docker API access — equivalent to root on the host. This proxy sits between containers and the Docker socket, only allowing whitelisted endpoints.
services:
socket-proxy:
image: zachbg/docker-socket-proxy:latest
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
CONTAINERS: 1
NETWORKS: 1
ports:
- "127.0.0.1:2375:2375"
traefik:
image: traefik:v3
depends_on:
- socket-proxy
environment:
DOCKER_HOST: tcp://socket-proxy:2375
# No docker.sock mount needed!
1 to allow)| Variable | Default | Docker API |
|---|---|---|
CONTAINERS | 0 | /containers/* |
IMAGES | 0 | /images/* |
NETWORKS | 0 | /networks/* |
VOLUMES | 0 | /volumes/* |
SERVICES | 0 | /services/* |
TASKS | 0 | /tasks/* |
NODES | 0 | /nodes/* |
BUILD | 0 | /build |
EXEC | 0 | /exec/* |
SYSTEM | 0 | /system/* |
INFO | 0 | /info |
VERSION | 0 | /version |
EVENTS | 0 | /events |
PING | 0 | /_ping |
| Variable | Default | Description |
|---|---|---|
POST | 0 | Allow POST requests (needed for container actions) |
DELETE | 0 | Allow DELETE requests |
| Variable | Default | Description |
|---|---|---|
LISTEN_PORT | 2375 | Port to listen on |
LOG_REQUESTS | false | Log all requests |
environment:
CONTAINERS: 1
NETWORKS: 1
environment:
CONTAINERS: 1
IMAGES: 1
NETWORKS: 1
VOLUMES: 1
EVENTS: 1
SYSTEM: 1
INFO: 1
VERSION: 1
POST: 1
DELETE: 1
environment:
CONTAINERS: 1
INFO: 1
VERSION: 1
EVENTS: 1
PING: 1
:ro127.0.0.1 or use Docker networks onlyContent type
Image
Digest
sha256:248868a13…
Size
6 MB
Last updated
6 months ago
docker pull zachbg/docker-socket-proxy