I have a Linux server running Jenkins (HTTP on port 8080) and the same server is also running Docker 1.12.1. I used some iptables rules (as per official Jenkins install docs) to redirect port 8080 to the host's port 80, so that default HTTP would work for Jenkins (i.e. http://myserver rather than http://myserver:8080):
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080 However these rules break Docker's ability to download the correct resources via HTTP during a docker build command. For instance, RUN apt-get update fails with multiple "failed to download" errors. Doing wget http://www.google.com inside the container returns the HTML for the Jenkins main page. HTTP GETs from the host work fine. Removing the iptables rules results in RUN apt-get update working again. So I think those iptables rules are interfering with docker's network mechanism.
Can such a port redirection coexist with Docker? If so, how would one go about writing iptables rules to solve this problem?