Put Docker Socket Proxy in front of every container that needs the Docker API instead of mounting docker.sock directly
This commit is contained in:
@@ -53,13 +53,35 @@ services:
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ./socket:/beszel_socket
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
environment:
|
||||
LISTEN: /beszel_socket/beszel.sock
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375
|
||||
# Do not remove quotes around the key
|
||||
KEY: ${KEY}
|
||||
depends_on:
|
||||
- docker-socket-proxy
|
||||
|
||||
docker-socket-proxy:
|
||||
image: lscr.io/linuxserver/socket-proxy:latest
|
||||
container_name: docker-socket-proxy-beszel
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
ports:
|
||||
- 127.0.0.1:2375:2375
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
environment:
|
||||
- CONTAINERS=1
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /run
|
||||
```
|
||||
|
||||
::note
|
||||
`beszel-agent` runs with `network_mode: host`, so it can't join a dedicated internal network like the other proxied stacks on this site; instead, **Docker Socket Proxy** publishes its API on `127.0.0.1` only, reachable from the agent via the host's own loopback interface, with just `CONTAINERS=1` enabled since the agent only needs to read container stats.
|
||||
::
|
||||
|
||||
::tip{icon=""}
|
||||
✨ __Tip:__ Add the Watchtower label to each container to automate updates.
|
||||
|
||||
@@ -122,11 +144,28 @@ services:
|
||||
container_name: beszel-agent
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
environment:
|
||||
LISTEN: ${PORT}
|
||||
KEY: ${KEY}
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375
|
||||
depends_on:
|
||||
- docker-socket-proxy
|
||||
|
||||
docker-socket-proxy:
|
||||
image: lscr.io/linuxserver/socket-proxy:latest
|
||||
container_name: docker-socket-proxy-beszel
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
ports:
|
||||
- 127.0.0.1:2375:2375
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
environment:
|
||||
- CONTAINERS=1
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /run
|
||||
```
|
||||
|
||||
And in `.env`:
|
||||
|
||||
Reference in New Issue
Block a user