Bug 1045173

Summary: Accessing Docker containers from outside network - adding firewall exceptions problem
Product: [Fedora] Fedora EPEL Reporter: ajinkya
Component: docker-ioAssignee: Lokesh Mandvekar <lsm5>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: el6CC: ajinkya, bugzilla, dwalsh, golang-updates, jkeck, jpoimboe, lsm5, mattdm, mgoldman, skottler, vbatts
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-28 17:57:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description ajinkya 2013-12-19 19:13:25 UTC
I am using Docker 0.7.0 to create containers on RedHat Enterprise Linux 6.5. When firewall is turned off containers can talk to outside world, but when firewall is on, container cannot be accessed from outside.

This is how I am running the docker and mapping a port from host to container

$ docker run -i  -t -p 3838:3838  shiny  "shiny-server"

Without firewall, I can access Node.js server running inside a container on port 3838 from outside network as http://servername:3838, but not with firewall turned on.

These are my default firewall rules –

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

I have tried opening a port 3838 by adding a rule as below, but it does not work

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3838 -j ACCEPT

Docker is creating a virtual NAT on the host machine, I am feeling that somehow firewall is blocking the packet forwarding from eth0 to docker 0

This is the output of $ifconfig (I have masked the server IP)

docker0   Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::87d:8dff:fed0:f16d/64 Scope:Link
          RX packets:408321 errors:0 dropped:0 overruns:0 frame:0
          TX packets:681809 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:126511933 (120.6 MiB)  TX bytes:924200959 (881.3 MiB)

eth0      Link encap:Ethernet  HWaddr 00:25:64:A8:5B:8F  
          inet addr:XXX.XXX.XXX.XXX  Bcast:XXX.XXX.XXX.XXX  Mask:
          inet6 addr: XXXX::XXX:XXXX:XXXX:XXXX/64 Scope:Link
          RX packets:29786186 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1137982 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4209047011 (3.9 GiB)  TX bytes:234657696 (223.7 MiB)

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8444 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8444 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4701771 (4.4 MiB)  TX bytes:4701771 (4.4 MiB)

Output of $docker version :

Client version: 0.7.0
Go version (client): go1.1.2
Git commit (client): 0ff9bc1/0.7.0
Server version: 0.7.0
Git commit (server): 0ff9bc1/0.7.0
Go version (server): go1.1.2
Last stable version: 0.7.2, please update docker

Output of $docker info:
Containers: 321
Images: 278
Driver: devicemapper
 Pool Name: docker-8:17-13239310-pool
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 56464.5 Mb
 Data Space Total: 102400.0 Mb
 Metadata Space Used: 59.5 Mb
 Metadata Space Total: 2048.0 Mb

I need help in making docker containers accessible from outside network without turning off the entire firewall.

Comment 1 Lokesh Mandvekar 2013-12-19 19:29:36 UTC
hi ajinkya, docker-io 0.7.2-1.el6 should be in epel-testing repo. Could you please check with this?

Please add +1 or -1 karma based on how it works for you here: https://admin.fedoraproject.org/updates/FEDORA-EPEL-2013-12416/docker-io-0.7.2-1.el6

Comment 2 ajinkya 2014-01-02 23:37:41 UTC
Hi Lokesh,

I just tested it with docker-io 0.7.2-1.el6  and I am still having the same issue.

Comment 3 bugzilla 2014-01-03 11:43:43 UTC
This is a Docker bug if you ask me. So this RedHat issue should be closed.

Docker should create the iptables rules it needs.

I had already created a Docker issue a few days ago:


Comment 4 Josh Poimboeuf 2014-01-30 04:05:43 UTC
This has been fixed upstream with https://github.com/dotcloud/docker/pull/3810.

Comment 5 bugzilla 2014-02-06 08:37:41 UTC
The Docker 0.8 release has the fixes.

After someone tests this on CentOS or RHEL and it works this bug should be closed.