How Do I Assign My Docker Containers an IP from the Host’s Network?

0
5
Asked By TechieExplorer42 On

I'm working on a wifi lab project for my students where they can learn about wifi without needing physical equipment. I've stumbled upon a couple of projects: mininet-wifi for simulating wifi stations and Containernet to containerize each station. My goal is to have the containers in my simulated network run on a bare-metal server with their own IPs. Specifically, I want to give the VM three network interfaces and allow the two containers to use those interfaces, maybe in a bridge-like setup. I've read that it's not ideal to give containers direct access to the host network but I really need this setup. Any suggestions on how to make this work?

2 Answers

Answered By ContainerWhisperer12 On

Yeah, definitely go with macvlan. This way, your containers can communicate on the same network as your bare-metal server without cramming everything through the host's IP. Just make sure to set it up correctly in your Docker Compose file to avoid network conflicts!

Answered By NetworkNerd99 On

You might want to use the macvlan driver instead of the host network mode. The host mode allows the container to share the host's IP and network stack, but macvlan creates a unique MAC address for each container. That way, your containers can request a separate IP address on the network, which should fit well with what you’re trying to achieve.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.