How to make Docker container accessible to other network machines through IP?

Lucas Rezende picture Lucas Rezende · Feb 29, 2016 · Viewed 10.9k times · Source

I need to create some docker containers that must be accessed by other computers at the same network.

Problem is that when I create the container, Docker gets IP addresses valid only within the host machine.

I already took a look at Docker documentation (Networking) but nothing has worked.

If I run ifconfig on my machine my IP address is 172.21.46.149. When I go inside the container (Ubuntu) and run ifconfig the IP address is 172.17.0.2. I need Docker to get, for example, 172.21.46.150.

How can I do it?

Answer

Harald Weber picture Harald Weber · Feb 29, 2016

You have to create a bridge on your host and assign that bridge to the container. This may help you: https://jpetazzo.github.io/2013/10/16/configure-docker-bridge-network/