I have a web service running on port 8080, which is made available on port 80 through IPTables like so:
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.0/8 --dport 80 -j REDIRECT --to-port 8080
This works, however attempting to reach
127.0.0.1:80 inside a Docker container fails. I assume this is because
lo within the container is a separate device inside a network namespace. Thus I attempted to do the following:
iptables -t nat -A OUTPUT -p tcp -d 172.17.0.0/16 --dport 80 -j REDIRECT --to-port 8080
172.17.0.0/26 is the range assigned to the
docker0 bridge interface. Connections to
172.17.42.1:80 (the IP assigned to
docker0) still fail inside the container.
There are no firewall rules other than the standard set created by Docker.
Why is this forwarding rule still failing?
- Ubuntu 14.04 (3.13.0-36-generic)
- Docker 1.2.0