0

I have planing to install docker but as we know default docker networking is in NAT mode so it has own IP on docker0 interface which is 172.17.42.x.

I want to reconfigure networking in full bridge mode so all my container get IP address from my LAN Wireless Router I am following this article and gave it a try, but it didn't work.

I have a question:

How container will get IP address? Or do I need to manually assign Local LAN IP address to docker container?

Or is there any best method to connect container to Local LAN do other people can access docker container?

EDIT:

If I add a bridge interface br0 and attach it to eth0, I won't able to ping outside. I am using brctl command to attach br0 to eth0.

Community
  • 1
  • 1
Satish
  • 16,544
  • 29
  • 93
  • 149
  • You need to be a little more detailed about what did not work. Broadly it is the correct approach. – Usman Ismail Dec 22 '14 at 17:17
  • Have you seen pipework? you could use --net=none and assign an IP with pipework. – hookenz Apr 28 '15 at 02:40
  • This question is related to http://stackoverflow.com/questions/35742807/docker-1-10-containers-ip-in-lan and http://stackoverflow.com/questions/29488637/docker-assign-ip-from-the-same-range-as-host#autocomment59566143 – Dreamcat4 Mar 12 '16 at 08:04
  • Maybe a little bit more effort to tune your spelling... [here](https://meta.stackoverflow.com/questions/291362/advice-for-non-native-english-speakers/291370#291370) are the most important things. – peterh Sep 09 '16 at 16:51

1 Answers1

1

The approach you might take is to create a virtual bridge, on which you put the external interface of your host and to which you have to attach your docker containers. Then, run your container in privileged mode and run dhclient in it, so that it asks your DHCP for an IP address. In this way your container should get dynamically its IP address as every normal host does.

PS Remember to run them with --net=none.

Here you can find a reference from which you can draw your inspiration: https://docs.docker.com/articles/networking/

mgaido
  • 2,987
  • 3
  • 17
  • 39
  • Thanks now i am able to setup `bridge` and it works! but now i am tying to expose `port 80` of container to outside world not working :( `iptables -t nat -A DOCKER -d 182.xx.xxx.xx/32 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.1.151:80` – Satish Dec 22 '14 at 20:34
  • Sorry, but I don't understand very well how your networking environment is and what is the behaviour you want to have. It would be nice to have a picture reprsenting it if possible, otherwise I might say you wrong or useless things. – mgaido Dec 23 '14 at 07:54
  • How does this work with net none? That causes no eth0 to be created in the container for dhclient to use... – Eric Woodruff Oct 05 '15 at 15:25
  • You have to configure it manually. If you do not put `--net=none`, the container is attacher to the Docker virtual bridge. If you want to attach it to another one, you should do it by yourself... At this link (https://docs.docker.com/articles/networking/#container-networking), you can find an example of how to do this... – mgaido Oct 06 '15 at 11:17