Here’s how I deploy SafeLine WAF with Docker Compose without the vendor’s curl | bash script.
I run homelab apps in containers (see Jellyfin on Alpine for a different stack), and SafeLine sits in front of them. My approach on a VPS: read the compose file, generate a real DB password, and keep the admin UI away from the world.
Following along from the channel? Email me at thelinuxitguy@gmail.com, but don’t send me your .env. Rotate secrets if you pasted them in chat.
Architecture & security principles
- No uninspected execution: nothing piped into
bash. - Package integrity: Docker comes from the official signed repo.
- Isolation: services run in Docker containers.
- Strong credentials: secrets are randomly generated.
- Network boundaries: the management UI stays behind a firewall or VPN.
Piping to bash is convenient, but it’s the same pattern malware uses. We’ll fetch compose.yaml, read it, then docker compose up.
Prerequisites
- A Debian/Ubuntu server you control. On Fedora/RHEL, use Docker’s official repo for those distros. Don’t use the
aptsteps on Rocky. - Root or sudo. I use
sudo docker composeinstead of adding users to thedockergroup, so the engine socket isn’t a second root. - Ports: 9443 (management UI), plus 80/443 if this box handles public traffic. Don’t put 9443 on the internet.
openssl,curl,gpg, and a firewall (ufwin the examples).- Enough disk under
/data/safelinefor images, Postgres, and logs.
If another reverse proxy already uses 80/443 here, plan your bindings first. Two processes can’t own 443.
Step 1: Securely install Docker (official repository method)
Skip curl -sSL https://get.docker.com | bash and add Docker’s signed repository instead.
For Ubuntu / Debian systems
# Update local package indexes and install prerequisitessudo apt-get updatesudo apt-get install -y ca-certificates curl gnupg
# Create directory for official keyringssudo install -m 0755 -d /etc/apt/keyrings
# Download Docker's official GPG key with standard TLS verificationcurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgsudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the authenticated Docker repositoryecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update and install Docker Engine and Compose pluginsudo apt-get updatesudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Verify Docker daemon statussudo systemctl is-active dockerYou should see active, and docker compose version should print a v2 version. If VERSION_CODENAME isn’t an Ubuntu release Docker supports, you’re on Debian. Swap the linux/ubuntu paths for linux/debian and use the Debian codename, per docs.docker.com.
Enable on boot:
sudo systemctl enable --now dockersudo docker run --rm hello-worldIf hello-world fails, fix registry access before SafeLine’s much larger pull.
Podman Compose might work, but SafeLine’s YAML is written for Docker, so I don’t use it on CoreOS. CoreOS stays on Podman Quadlets for DNS (AdGuard).
Step 2: Prepare a dedicated application workspace
# Create application root directorysudo mkdir -p /data/safeline
# Make your user the owner of the foldersudo chown -R $USER:root /data/safeline
# Set ownership to root with strict permissionssudo chmod 750 /data/safelinecd /data/safeline/data/safeline is separate from /home and easy to snapshot. chmod 750 keeps other local users out of the compose file and .env. It’s fine to chown it to $USER:root and run compose as root.
Step 3: Fetch and audit the SafeLine Docker Compose artifacts
# Download the compose configuration using enforced TLS verificationsudo curl -fsSL "https://waf.chaitin.com/release/latest/compose.yaml" -o /data/safeline/compose.yaml
# Inspect the file contents for unexpected images, volumes, or network privilegesless /data/safeline/compose.yamlAudit checklist during inspection:
- Images come from trusted registries (e.g.,
chaitin/*).- Ports match the expected services (management
9443, web80/443).- Host volumes point only to
/data/safeline/.- Look for
privileged: true, Docker socket mounts (/var/run/docker.sock), andnetwork_mode: host. They aren’t automatically bad, but stop and read if you see the socket.
curl -fsSL fails on TLS errors instead of writing half a file. If the URL 404s, get the new path from the vendor’s docs and still less before up.
Keep a copy to diff later:
sudo cp /data/safeline/compose.yaml /data/safeline/compose.yaml.$(date +%F)Step 4: Configure environment & cryptographic secrets
Generate a random PostgreSQL password. Never use a default.
# Navigate to deployment directorycd /data/safeline
# Generate a 32-character high-entropy secret for PostgreSQLPOSTGRES_SECURE_PASS=$(openssl rand -hex 16)
# Create the environment configuration file with secure permissionssudo touch .envsudo chmod 600 .env
# Populate .env configurationsudo tee .env > /dev/null <<EOFSAFELINE_DIR=/data/safelineIMAGE_TAG=latestMGT_PORT=9443POSTGRES_PASSWORD=${POSTGRES_SECURE_PASS}SUBNET_PREFIX=172.22.222IMAGE_PREFIX=chaitinARCH_SUFFIX=RELEASE=REGION=-gMGT_PROXY=0EOFThe tee heredoc expands POSTGRES_SECURE_PASS in your shell. If that variable is empty, Postgres starts with an empty password. sudo cat /data/safeline/.env should show mode 600, and this should show a long hex string:
sudo grep POSTGRES_PASSWORD /data/safeline/.envOn a VPS you care about, swap IMAGE_TAG=latest for a pinned tag once you have a known-good deploy. SUBNET_PREFIX can’t collide with another Docker network or your LAN (172.22.222.0/24 style). If docker compose up complains about overlapping pools, pick another prefix.
If docker compose config errors on unknown variables, the vendor changed the .env keys. Check the comments in the YAML. Don’t invent keys.
Step 5: Validate and launch services
cd /data/safeline
# Verify environment variable substitution and syntaxsudo docker compose config
# Pull container images over HTTPS with signature verificationsudo docker compose pull
# Launch SafeLine in detached modesudo docker compose up -dconfig prints the YAML with your password filled in, so don’t paste it into a ticket. If it shows the sample’s default password, your .env wasn’t read (--env-file / working directory). Always cd /data/safeline first. The pull can take a while.
Step 6: Verify service health & initial setup
# Monitor container statussudo docker compose ps
# View initialization logs to ensure DB setup and service startup succeed without errorssudo docker compose logs -f --tail=50ps should show management, postgres, and related services Up. If postgres restart-loops, the password changed after the volume was created. Editing .env won’t fix it. Restore from backup, or wipe it only if you accept losing your WAF config.
Open the management console at:
https://<YOUR-SERVER-IP>:9443
Expect a self-signed cert warning. Don’t click through it on a public IP. Use an SSH tunnel or VPN:
ssh -L 9443:127.0.0.1:9443 user@your-serverThen open https://127.0.0.1:9443 locally, and use the firewall rules below so 9443 isn’t open to the world.
Step 7: Post-installation hardening & maintenance
- Firewall rules (
ufw/iptables):
Only allow port9443from trusted admin IPs or a VPN (e.g., Tailscale / WireGuard).
sudo ufw allow from <YOUR_ADMIN_IP> to any port 9443 proto tcpsudo ufw deny 9443/tcpsudo ufw allow 22/tcpsudo ufw allow 80/tcpsudo ufw allow 443/tcpsudo ufw enablesudo ufw statusReplace <YOUR_ADMIN_IP>. With Tailscale, allow the tailnet prefix instead of your WAN IP (it changes). Order matters in ufw: a deny 9443 rule can block your allow depending on numbering. Check ufw status numbered and test from a non-admin IP.
If this host doesn’t serve public traffic on 80/443, don’t allow those ports.
- Obtain initial admin credentials:
sudo docker exec -it safeline-mgt resetadminCheck sudo docker compose ps for the real container name. If resetadmin doesn’t exist in your image tag, use the vendor’s current reset docs. Don’t guess SQL against Postgres. Change the admin password after your first login.
-
Backup strategy:
Back up/data/safeline/regularly (.env, database volumes, and SSL certificates). Stop compose before snapshotting/data/safelinefor a consistent Postgres copy, or usepg_dumpinside the DB container if you know the schema. Test a restore on a spare VM. -
Updating SafeLine securely:
cd /data/safelinesudo cp compose.yaml compose.yaml.baksudo curl -fsSL "https://waf.chaitin.com/release/latest/compose.yaml" -o compose.yamldiff -u compose.yaml.bak compose.yamlsudo docker compose pullsudo docker compose up -dRead the diff. That’s the whole point of skipping curl | bash.
Troubleshooting
docker compose: command not found: you have classicdocker-composeor nothing. This guide uses the v2 plugin (docker compose).- Permission denied on docker.sock: use sudo, or
newgrp dockerafter adding your user to the group. Thedockergroup is root-equivalent. - Can’t reach 9443: firewall, wrong
MGT_PORT, or compose binds to127.0.0.1only. Checksudo ss -tulpn | grep 9443. - Let’s Encrypt / public site behind the WAF: only point DNS here once the WAF owns 80/443, not a leftover nginx.
- Resource usage: a WAF plus Postgres isn’t a Pi Zero project. If
compose psis healthy but the site times out, check CPU and disk.
Wrap-up
Keep 9443 off the public internet, and remember a WAF doesn’t replace patching your apps or running nftables/ufw.
Best regards,
The Linux IT Guy