PortGate

Blueprints · Docker & Databases

Production 15 min · Docker

Docker socket proxy least privilege

Replaces a raw docker.sock mount with tecnativa/docker-socket-proxy. POST is off, the socket is mounted read-only, and the proxy port is localhost.

Live config

Baked-in protections

Step 1 · yaml

Compose file

/opt/socket-proxy/compose.yaml

Point other compose files at tcp://127.0.0.1:2375 instead of the socket.

services:
  socket-proxy:
    image: tecnativa/docker-socket-proxy:latest
    environment:
      CONTAINERS: 1
      IMAGES: 1
      NETWORKS: 1
      SERVICES: 1
      POST: 0
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - "127.0.0.1:2375:2375"
    read_only: true
    security_opt:
      - no-new-privileges:true
    restart: unless-stopped

Step 2 · bash

Start command

/opt/socket-proxy/up.sh

Written, not run.

#!/bin/sh
set -eu
cd "/opt/socket-proxy"
docker compose up -d