Docker Community Forums

Share and learn in the Docker community.

How to assign public IP address to Docker container, so that I can access them on my network?

(Jklepek) #21

I created new virtual machine on my laptop and turned on the promiscuous mode, but the macvlan driver still didn’t work for me.

(Jklepek) #22

Yes, I believe so. Check this article

(Rkuba) #23

Thanks for explanations - now I have less questions:
1 Maybe you do not need to ask the host for IP and port - If you have connected there you already know it
2 Even if you must ask, containerized application can correctly advertise published address- the simplest brute force approach is to pass this address as parameter or as environment variable when staring container - but as I said I’d opt for option 1.
Regards, Kuba

(Jklepek) #24

1 Unfortunately, I am only a humble tester, so I cannot change the code.
2 That is the whole problem, you can’t assign the same IP as host and other IPs are not accessible from the network. That’s why I tried macvlan driver, which is supposed to connect the container directly to company network.

(Rkuba) #25

As a Tester u sometime have to raise a bug against ill-behaved application being developed by your developers :stuck_out_tongue_winking_eye:.

(Jklepek) #26

Of course, I discussed it with them. I wanted to try something before interfering with the code, because according to what I’ve read online, this should be possible with macvlan.

(Gabrielfsousa) #27

did you found any solution to the container ip plublic ?

(Jklepek) #28

Yes, I got it working on my home network. I created Hyper-V virtual machine with ubuntu. It seems, that the problem really was in enabling the promiscuous mode on the external virtual switch.
Now I just have to make it work at work… :smiley:

(Gabrielfsousa) #29

i used macvlan ,
how on host1 i can ping container on host3 ?

(Jklepek) #30

Well, using macvlan allows the containers to use the host’s interface (eth0, …) and connect directly to network, so they appear like any other PC in the network. So, you should be able to ping the containers directly by their IP address.

(Gabrielfsousa) #31

i’m using macvlan, but to create a private network, i’m not using host network, is possible ?

(Jklepek) #32

I believe you would need to use overlay network.

(Gabrielfsousa) #33

with overlay, host can ping containers ip ?

(Jklepek) #34

It was mentioned already. If you want to ping host, you would need to setup macvlan network on host as well. Read the link, I posted here.

(Gabrielfsousa) #35

ok, but how host1 pings containers on host2 ?

(Sinusx86) #36


I have a similar task.
Each container in my app is microservice. Some are done, some are in development phase.
I want to test new microservice with debuger, and services from containers has to interact with my microservice in docker host bidirectional way.
So I have to gather containers and my host docker in one network.

I have done it in debian using --network host option.
Is it possible to do it in windows 10 using other network mode than host, because “–network host” in windows doesn’t have support according to

Should I create overlay, or macvlan?
Have anybody successful experience in similar task?


I have created the docker compose image file for a flask web Application.Every time the containers IP Address are changing…it is not hitting the web application IP how to resolve the dynamic changing IP Address.please help me.