Ubuntu – Open ports to Docker containers

dockernetworkingUbuntu

I'm starting with docker, just triying to run a Docker container with a web aplication and trying to see it in our local network.

I have installed a fresh Ubuntu 14 LTS in VirtualBox, without any extra services (no GUI, no LAMP, no OpenSSH…), and then installed only Docker:

curl -sSL https://get.docker.com/ | sh

and I have run an Odoo (OpenERP) container (previusly run postgree container)

docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres
docker run -p 127.0.0.1:8069:8069 --name odoo --link db:db -t odoo

Very simple. It looks like it is working. I have not installed browser, but I connected via telnet to 127.0.0.1:8069 and sent GET request. It answered.

Now I need to access the service from outside. How?

  • VirtualBox network interface is configured as bridge.

  • I have set a fixed IP (192.168.0.150) in Ubuntu eth0 interface.

  • UFW is disabled

  • I can ping to 192.168.0.150 form other computers, and ubuntu answers.

  • But browser doesnt detect anything at 192.168.0.150:8069

  • Can't connect via telnet to 192.168.0.150:8069

I suppose it must be some configuration of port redirection or interface mapping. Could you help me, please? 🙂

Best Answer

Finally I found the answer. Problem was the port assignement. If you set:

-p 127.0.0.1:8069:8069

you are exposing ONLY localhost. This is great security option if you need only a local service, and want to access it only from the server. But, if you want to expose the port to ALL interfaces, just type:

-p 8069:8069

Then, you can access the service through the network via eth0 interface :)

Related Topic