I'm running Docker inside a Debian VM on a bare metal server managed by Proxmox, and I want my Docker containers to receive IP addresses from my network's router, which is also acting as the DHCP server. I've read that using the macvlan driver in Docker is necessary for this, but when I create a container under this network, it only gets an internal IP address instead. Some articles suggest plugins or that this simply isn't a supported feature in Docker. I'm looking for any guidance on whether this is even possible, and if so, how to approach it.
4 Answers
If you're trying to expose multiple services, using a reverse proxy is the way to go. You can manage all your services through one public IP by directing traffic based on URLs. It's actually more secure this way, preventing your backend applications from being directly exposed.
You really don't need to assign IP addresses manually to your containers. By default, Docker manages IPs dynamically within its own network. You can access services running in containers through the host IP address. If you have a special case where a container needs its own public IP (like a DNS server), then MACVLAN can work for that, but be cautious about the overall necessity.
It's surprising to see people forcing IP assignments when Docker provides automatic management. Instead of complicating things, consider using a reverse proxy alongside your own DNS to handle multiple services efficiently without needing separate IPs for each.
You might want to reconsider this approach. It's common for beginners to think of containers like virtual machines, but they're not quite the same. Typically, individual containers don't need their own public IP addresses. You can expose necessary ports from the Docker host instead. Alternatively, look into setting up a reverse proxy for better management. Using MACVLAN to assign individual IPs can complicate things unnecessarily, so it's generally not recommended.
Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux