Score:0

Running two containers on a single macvlan IP?

co flag

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?

vidarlo avatar
ar flag
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?
co flag
@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.
fizzers123 avatar
se flag
This worked for me [network_mode: service:web](https://stackoverflow.com/questions/43300613/multiple-docker-compose-container-single-ip)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.