1

I've been doing some experimenting with Docker and Portainer on Ubuntu Server, and I had a use case pop up that I was curious to know if it would be possible to implement.

  • The Docker host is on 192.168.1.100
  • I set up macvlan network
  • I create a new container (App A) that uses port 1000 and give it the macvlan IP address 192.168.1.200
  • I then want to create a new container (App B) that uses port 2000, but also have the IP address 192.168.1.200
  • I can't create App B because .200 is already in use

So my question is, is it possible to have two containers, both using 192.168.1.200, exposing ports 1000 and 2000, but not being accessible on 192.168.1.100? In other words, made it look like .100 and .200 are physically separate machines?

3
  • Why do you want to use macvlan? And yes, in general, one machine may have as many IP's as you please, and one feature of macvlan is that you'll have separate L2 addressing for each container, so they can control IP's themself. So - why do you want this, and have you tried what you suggest?
    – vidarlo
    Dec 3, 2021 at 17:23
  • @vidarlo I'm not particularly wanting do this, but while I have used Docker before, I don't know much about it (having come from a VM background instead), so I've been playing around with Portainer and Docker at home. I noticed the bridge network mode, and ipvlan / macvlan modes and wondered if one could fire up two containers using an IP that wasn't the host's (maybe as a "this IP is where webapps live, this one is where databases live" sort of thing). Curiosity / wanting to learn more about network modes, you could say.
    – Grayda
    Dec 4, 2021 at 1:37
  • This worked for me network_mode: service:web
    – fizzers123
    Jan 31, 2022 at 17:44

0

You must log in to answer this question.

Browse other questions tagged .