Loading…
Loading documentation...
Deploy a multi-container Docker Compose stack with persistent volumes, private networking, health checks and registry image pulls.
Commands checked on 2026-11-12 with Docker Engine 27.3, Docker Compose 2.29, sau CLI 0.2.0.
You will have a three-service production Docker Compose stack—a web API, PostgreSQL 17 with a persistent named volume, and a Caddy HTTPS reverse proxy—running on an isolated Managed Docker host with internal container-only database networking, health-gated startup ordering, and private OCI registry authentication.
/containers or Home > Create a resource (/dashboard/store), or any Ubuntu 24.04 Linux VPS with Docker Engine installed./dashboard/container-registry) if you are pulling proprietary application images.203.0.113.45 in the examples below) with inbound ports 80 and 443 allowed in Network > Firewall (/dashboard/network?tab=firewall).Open a browser terminal on Access > Access console (/dashboard/console) or connect via sau ssh <instance-id>, then create an isolated directory /opt/stacks/prod-api with restrictive permissions on .env:
sudo install -d -m 0755 /opt/stacks/prod-api
cd /opt/stacks/prod-api
sudo tee .env > /dev/null <<'EOF'
POSTGRES_DB=app_prod
POSTGRES_USER=app_writer
POSTGRES_PASSWORD=replace_with_32_char_random_secret
APP_DOMAIN=api.example.com
APP_IMAGE=ghcr.io/your-org/prod-api:1.4.2
EOF
sudo chmod 0600 .env
If your image lives in your private Compute > Container registry (/dashboard/container-registry), inspect your registry endpoint with the CLI and sign in on the Docker host using a scoped pull token:
# On your workstation: inspect your private registry
sau acr list -o table
# On the Managed Docker host: sign in with a read-only registry token
echo "YOUR_SCOPED_PULL_TOKEN" | sudo docker login registry.serversareup.com -u token --password-stdin
compose.yaml with isolated internal networkingCreate /opt/stacks/prod-api/compose.yaml with two networks (edge for Caddy + API, and backend marked internal: true so PostgreSQL has zero outbound or inbound internet route) and service_healthy startup dependencies:
sudo tee /opt/stacks/prod-api/compose.yaml > /dev/null <<'EOF'
services:
db:
image: postgres:17-alpine
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- backend
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s
timeout: 3s
retries: 5
api:
image: ${APP_IMAGE}
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
PORT: "8080"
networks:
- backend
- edge
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8080/healthz || exit 1"]
interval: 15s
timeout: 3s
retries: 3
proxy:
image: caddy:2.8-alpine
restart: unless-stopped
depends_on:
api:
condition: service_healthy
ports:
- "80:80"
- "443:443"
- "443:443/udp"
command: caddy reverse-proxy --from ${APP_DOMAIN} --to api:8080
volumes:
- caddy_data:/data
- caddy_config:/config
networks:
- edge
networks:
edge:
backend:
internal: true
volumes:
pgdata:
caddy_data:
caddy_config:
EOF
Validate variable interpolation first, then pull pinned images and bring the stack up in detached mode:
cd /opt/stacks/prod-api
sudo docker compose config -q
sudo docker compose pull
sudo docker compose up -d --remove-orphans
Inspect container health states on the host and verify that PostgreSQL is unreachable from the public internet while the HTTPS API answers cleanly:
sudo docker compose -f /opt/stacks/prod-api/compose.yaml ps
curl -fsSI https://api.example.com/healthz
Every container in docker compose ps should report (healthy) (or Up for Caddy), and sudo ss -tlnp on the host should show only ports 80 and 443 bound publicly—never 5432 or 8080.
"5432:5432" in compose.yaml accidentally exposes PostgreSQL bypassing ufw on Linux. Docker manipulates iptables/nftables FORWARD chains directly on standard Linux installations. Never add ports: to database containers, and keep your perimeter firewall default-closed on Network > Firewall (/dashboard/network?tab=firewall) so only 80 and 443 traverse the datacenter edge!api fails at boot with getaddrinfo ENOTFOUND db or connection refused. Always pair depends_on: db: condition: service_healthy with a real pg_isready health check so the API container waits until PostgreSQL accepts TCP connections.docker compose pull updates. Schedule weekly cleanup of unused image layers (sudo docker image prune -af --filter "until=168h")—never pass --volumes to prune in production.@sha256 digests on every image (postgres:17.2-alpine, caddy:2.8.4-alpine) rather than floating :latest tags.docker compose exec -T db pg_dump -Fc ...) to Home > Cloud storage & pub/sub (/dashboard/blob-storage) every night rather than copying raw /var/lib/docker/volumes while PostgreSQL is writing WAL segments./dashboard/container-registry).Every Servers Are Up virtual machine and container includes an integrated HTML5 browser-based SSH, RDP, and VNC console in your dashboard, default-off inbound firewall rules with per-IP allow-lists, and full programmatic control via REST API v1 and Model Context Protocol (MCP). Explore our Virtual Datacenter Plans or reach out to Servers Are Up Support.