feat(hermes_infra): inline docker_socket_proxy into hermes_squid stack

PR #1 originally shipped docker-socket-proxy as a standalone stack at
docker_socket_proxy/stack-compose.yml, exposed via an external overlay
network 'socket_proxy' so other stacks could attach to it.

Inlining it into hermes_squid/stack-compose.yml as a new service:
  - same deploy / rollback unit as the rest of hermes_infra
  - joins the 'admin' overlay network so any hermes_infra service can reach
    it as 'docker_socket_proxy:2375'
  - default policy unchanged: read-only PING / EVENTS / VERSION (matches
    image defaults); every other endpoint explicitly denied
  - removes the standalone socket_proxy overlay declaration (no longer
    needed -- consumers attach via 'admin' instead)

Brencher config backend/configs/docker_socket_proxy.py is updated
in a follow-up commit to point its docker_compose_path at
hermes_squid/stack-compose.yml.
This commit is contained in:
hermes
2026-08-25 19:08:38 +00:00
parent fbed72401a
commit 449cbaa316
2 changed files with 42 additions and 82 deletions
-82
View File
@@ -1,82 +0,0 @@
# Stack compose for tecnativa/docker-socket-proxy
# https://github.com/Tecnativa/docker-socket-proxy
#
# Lightweight HAProxy-based security proxy in front of the host Docker socket.
# Exposes a TCP endpoint that filters the Docker API by environment variables,
# so any consumer of the docker socket (portainer, watchtower, diun, ...)
# only gets the verb/path scope we explicitly grant.
#
# Designed for Docker swarm. The service binds to 127.0.0.1:2375 on the host --
# NEVER publish this port on a public network. Downstream services reach it via
# the `socket_proxy` overlay network with `DOCKER_HOST=tcp://docker_socket_proxy:2375`.
#
# Default policy matches the image's defaults:
# - granted by default: EVENTS, PING, VERSION (read-only health)
# - revoked by default: everything else (POSTs blocked, AUTH/SECRETS/SECURITY off)
#
# Edit the environment block below to widen the scope for a specific consumer.
version: "3.8"
services:
docker_socket_proxy:
image: tecnativa/docker-socket-proxy:latest
restart: always
# Privileged is required for bind-mounting the host docker socket in
# SELinux/AppArmor-enforced environments. The image is read-only and the
# socket is the only surface it touches.
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
# Listening interface inside the container. 0.0.0.0:2375 is fine because
# the port is only published to localhost on the host (see ports below).
BIND_CONFIG: ":2375"
LOG_LEVEL: "info"
# -- Access scope --------------------------------------------------
# Toggle any of these to 1 to grant that API section. Leave at 0 (or omit)
# to keep the upstream default -- denied.
CONTAINERS: 0 # GET /containers, /containers/json, ...
IMAGES: 0 # GET /images, /images/json
NETWORKS: 0 # GET /networks
VOLUMES: 0 # GET /volumes
SERVICES: 0 # GET /services (swarm)
TASKS: 0 # GET /tasks (swarm)
NODES: 0 # GET /nodes (swarm)
POST: 0 # globally allow POST; off = read-only proxy
# Uncomment when running diun / watchtower-style consumers:
# CONTAINERS: 1
# IMAGES: 1
# POST: 1
# Bind to the swarm node that hosts the docker socket (odroid in this repo).
# On a single-host swarm this still works; on a multi-node swarm the
# socket is local to each manager/worker -- drop the constraint and add
# replicas, or run one proxy per node.
ports:
- target: 2375
published: 2375
protocol: tcp
mode: host
networks:
- socket_proxy
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.hostname == odroid
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
networks:
# External so other stacks (portainer, watchtower, ...) can
# networks:
# socket_proxy:
# external: true
# and reach this service by name.
socket_proxy:
driver: overlay
+42
View File
@@ -112,6 +112,48 @@ services:
restart_policy:
condition: on-failure
docker_socket_proxy:
# tecnativa/docker-socket-proxy: HAProxy in front of the host Docker socket,
# filtering the Docker REST API by URL prefix. Inlined here so the proxy
# deploys + tears down with the rest of hermes_infra.
# https://github.com/Tecnativa/docker-socket-proxy
image: tecnativa/docker-socket-proxy:latest
hostname: docker_socket_proxy
privileged: true # required for /var/run/docker.sock bind in SELinux/AppArmor contexts
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- admin # so hermes_infra services can reach it as docker_socket_proxy:2375
environment:
BIND_CONFIG: ":2375"
LOG_LEVEL: "info"
# Default policy matches the image defaults: read-only PING / EVENTS / VERSION.
# Anything else (POST, CONTAINERS, IMAGES, SERVICES, ...) must be explicitly
# toggled to 1 by a consumer that has a reason to need it. NEVER widen the
# scope from a generic change like this one.
CONTAINERS: 0
IMAGES: 0
NETWORKS: 0
VOLUMES: 0
SERVICES: 0
TASKS: 0
NODES: 0
POST: 0
ports:
- target: 2375
published: 2375
protocol: tcp
mode: host # bind on the swarm manager (odroid), not on the ingress
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.hostname == odroid # the swarm manager; socket is local
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
networks:
hermes_proxy: