Search code examples
dockerportforwarding

Docker port forwarding: connection timed out


I'm using the nginx:alpine Docker image, running it like so:

c@makina ~> docker run -itp 8000:80 nginx:alpine

The port is shown as listening in lsof:

c@makina ~> sudo lsof -i :8000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME docker-pr 3653 root 4u IPv4 2025067 0t0 TCP *:8000 (LISTEN)

However, when trying to access it, I get a connection timeout:

c@makina ~> http :8000 http: error: Request timed out (30s).

Starting another container with a link to the nginx container lets me access it, however:

c@makina ~> docker run -it --link ${CONTAINER_ID}:nginx alpine:3.6 /bin/sh / # curl -s -D - -o /dev/null http://nginx/ HTTP/1.1 200 OK ...

The docker0 bridge (and the br-* bridge and veth* interfaces) are up on the host, and both lo and eth0 are up in the nginx container.

The firewall is disabled on the host:

root@makina /h/c# service iptables status * status: stopped

Any ideas?


Solution

  • I figured out the issue was that the loopback interface was not up. Adding it to /etc/network/interfaces and running ifup lo fixed the issue.