Port Binding
Port binding determines two things: which port number a service listens on, and which network interface (IP address) the service is accessible from. The combination of IP address and port is called a socket.
In Docker, port binding is specified in docker-compose.yml as HOST_IP:HOST_PORT:CONTAINER_PORT. Omitting the HOST_IP (e.g., 8080:80) binds to 0.0.0.0, which means all interfaces including the public internet-facing interface. This is the most common cause of accidentally exposed services.
Interface Binding Options
0.0.0.0:8080:80 — all interfaces, publicly accessible. 127.0.0.1:8080:80 — loopback only, localhost access only. 192.168.1.x:8080:80 — specific private interface, LAN only.
Why 0.0.0.0 Is Dangerous
Services bound to 0.0.0.0 are reachable from any network interface including the public internet. Databases (Redis :6379, PostgreSQL :5432, MongoDB :27017) are frequently exposed this way via Docker without the operator realising. Combined with the Docker UFW bypass issue, these services bypass firewall protection entirely.
Related Tools
Fix Guides
Frequently Asked Questions
ss -tlnp or netstat -tlnp. Look for 0.0.0.0:PORT in the Local Address column. For Docker containers, run docker ps --format 'table {{.Ports}}'.127.0.0.1 or a private network interface. Public exposure of database ports is one of the most common causes of data breaches on VPS servers.