Hi, I am very new in docker and I’m confused about the varieties of how to set up a network.
My goal is to create multiple server containers which like to communicate on the same port. Therefore, the server containers should receive a different ip each.
I’ve tried to set up a ipvaln network but ran into two problems:
I have to define IPs manually by myself
There is no communication with the host network anymore.
So, how would I manage to reach my goal? Is it composable out of the box? Or are third party plugins needed? Or is a swarm needed?
Not necessarily, as docker provides ipam to assign ip addresses from the pool you specify as --ip-range when creating the ipvlan network.
Again not necessarily: the restriction is that a ipvlan (or macvlan) child interface (=what the containers use) can not communicate with its parent interface (=what the host uses). As a workaround you can assign a ipvlan child interface to the host as well. Most blog posts that discuss ipvlan/macvlan discuss this as well.
Note on Swarm: you can not assign static ip addresses for Swarm services.
Like @bluepuma77 wrote, you can use a reverse proxy if it’s for layer 7 http traffic. It works on layer 4 for https traffic leveraging SNI as well.