Getting IP Addresses for Docker Containers from an External DHCP Server

0
4
Asked By CuriousCoder87 On

I could use some help! I'm running Docker inside a Debian VM on a baremetal server with Proxmox. The baremetal server is connected to a network where the router is also the DHCP server. I want my Docker containers in the Debian VM to receive IP addresses directly from this router, so I can manage them centrally. I've read that I need to set up a network using the macvlan driver in Docker, but when I create a new container in that network, it only gets an IP from the subnet I specified for that network instead of one from the router. Some articles suggest that Docker doesn't support this without extra plugins. I'm wondering if it's even possible to do what I want or if I should rethink my approach. Any guidance would be appreciated!

3 Answers

Answered By NetworkGuru99 On

Honestly, if you're assigning IPs to containers, you're complicating things unnecessarily. Containers communicate via the host's IP address. If they are on the same custom bridge network, they can resolve each other's names dynamically without needing fixed IPs. Only use MACVLAN if a specific container needs a public-facing IP for a service like DNS or DHCP.

Answered By TechieNerd77 On

You might want to reconsider. Many beginners think containers are like virtual machines and try to assign them their own IP addresses directly from the router. In reality, you generally don't need individual IPs for each container. Instead, you should expose just the necessary ports on the Docker host's IP. Consider using a reverse proxy to manage your traffic more efficiently. Containers aren't designed to be network devices, so it's usually better to let Docker handle networking for you.

Answered By ProxyMaster3000 On

If you want to expose multiple services, using a reverse proxy is the way to go. It allows all your services to share a single public IP while routing requests to the right container based on the URL. It's not secure to expose services directly without a reverse proxy/load balancer, so keep that in mind. You might find the Docker MACVLAN documentation helpful if you still want to go that route.

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.