$ -weight: 600;">sudo ufw default deny incoming
-weight: 600;">sudo ufw default allow outgoing
-weight: 600;">sudo ufw allow 22/tcp
-weight: 600;">sudo ufw allow 80/tcp
-weight: 600;">sudo ufw allow 443/tcp
-weight: 600;">sudo ufw -weight: 500;">enable
-weight: 600;">sudo ufw default deny incoming
-weight: 600;">sudo ufw default allow outgoing
-weight: 600;">sudo ufw allow 22/tcp
-weight: 600;">sudo ufw allow 80/tcp
-weight: 600;">sudo ufw allow 443/tcp
-weight: 600;">sudo ufw -weight: 500;">enable
-weight: 600;">sudo ufw default deny incoming
-weight: 600;">sudo ufw default allow outgoing
-weight: 600;">sudo ufw allow 22/tcp
-weight: 600;">sudo ufw allow 80/tcp
-weight: 600;">sudo ufw allow 443/tcp
-weight: 600;">sudo ufw -weight: 500;">enable
-weight: 500;">docker run -d \ --name pg \ -p 5432:5432 \ -e POSTGRES_PASSWORD=changeme \ postgres:16
-weight: 500;">docker run -d \ --name pg \ -p 5432:5432 \ -e POSTGRES_PASSWORD=changeme \ postgres:16
-weight: 500;">docker run -d \ --name pg \ -p 5432:5432 \ -e POSTGRES_PASSWORD=changeme \ postgres:16
-weight: 600;">sudo iptables -L DOCKER -n -v
-weight: 600;">sudo iptables -t nat -L DOCKER -n -v
-weight: 600;">sudo iptables -L DOCKER -n -v
-weight: 600;">sudo iptables -t nat -L DOCKER -n -v
-weight: 600;">sudo iptables -L DOCKER -n -v
-weight: 600;">sudo iptables -t nat -L DOCKER -n -v
-weight: 500;">docker run -d \ --name pg \ -p 127.0.0.1:5432:5432 \ -e POSTGRES_PASSWORD=changeme \ postgres:16
-weight: 500;">docker run -d \ --name pg \ -p 127.0.0.1:5432:5432 \ -e POSTGRES_PASSWORD=changeme \ postgres:16
-weight: 500;">docker run -d \ --name pg \ -p 127.0.0.1:5432:5432 \ -e POSTGRES_PASSWORD=changeme \ postgres:16
services: db: image: postgres:16 ports: # Bind explicitly to loopback — not reachable from the network - "127.0.0.1:5432:5432" environment: POSTGRES_PASSWORD: changeme
services: db: image: postgres:16 ports: # Bind explicitly to loopback — not reachable from the network - "127.0.0.1:5432:5432" environment: POSTGRES_PASSWORD: changeme
services: db: image: postgres:16 ports: # Bind explicitly to loopback — not reachable from the network - "127.0.0.1:5432:5432" environment: POSTGRES_PASSWORD: changeme
services: db: image: postgres:16 # No ports section at all environment: POSTGRES_PASSWORD: changeme api: image: my-api depends_on: - db environment: # Resolves via Docker's internal DNS DATABASE_URL: postgres://postgres:changeme@db:5432/postgres
services: db: image: postgres:16 # No ports section at all environment: POSTGRES_PASSWORD: changeme api: image: my-api depends_on: - db environment: # Resolves via Docker's internal DNS DATABASE_URL: postgres://postgres:changeme@db:5432/postgres
services: db: image: postgres:16 # No ports section at all environment: POSTGRES_PASSWORD: changeme api: image: my-api depends_on: - db environment: # Resolves via Docker's internal DNS DATABASE_URL: postgres://postgres:changeme@db:5432/postgres
# Block everything coming in on the public interface first
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -j DROP # Then explicitly allow established connections back
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -m conntrack \ --ctstate ESTABLISHED,RELATED -j ACCEPT # Allow your office IP
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -s 203.0.113.42 -j ACCEPT
# Block everything coming in on the public interface first
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -j DROP # Then explicitly allow established connections back
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -m conntrack \ --ctstate ESTABLISHED,RELATED -j ACCEPT # Allow your office IP
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -s 203.0.113.42 -j ACCEPT
# Block everything coming in on the public interface first
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -j DROP # Then explicitly allow established connections back
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -m conntrack \ --ctstate ESTABLISHED,RELATED -j ACCEPT # Allow your office IP
-weight: 600;">sudo iptables -I DOCKER-USER -i eth0 -s 203.0.113.42 -j ACCEPT - Default to not publishing ports. If services only talk to each other, use a Docker network.
- If you must publish, bind to 127.0.0.1 unless you have a specific reason not to.
- For anything truly public (80, 443), put it behind a reverse proxy in its own container, and let that be the only thing with a 0.0.0.0 binding.
- After deploying anything, run nmap or ss -tlnp from outside the box. Don't trust ufw -weight: 500;">status. Trust what the network actually sees.
- Never run a database with the default password. I know. I know. Yet here we are.