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

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

Yes, I believe so. Check this article https://sreeninet.wordpress.com/2016/05/29/docker-macvlan-and-ipvlan-network-plugins/

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

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.

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

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.

did you found any solution to the container ip plublic ?

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:

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

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.

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

I believe you would need to use overlay network.

with overlay, host can ping containers ip ?

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.

ok, but how host1 pings containers on host2 ?

Hi!

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 https://docs.docker.com/network/network-tutorial-host/

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 Address.so how to resolve the dynamic changing IP Address.please help me.