Docker Container With DHCP from my Router

  • Hi


    Sorry if there's. a answer about that over there, but I really didn't find it.


    I'm new on Docker. I have a OMV5 installation with some services and want to port all of them to Docker container.

    But I want that each container has it's own real fixed IP address, given by my router DHCP.


    I created a container in Portainer, Configured it to use macvlan and it works. But the IP address is assigned by Docker, and not the DHCP of my router. I don't even know if this IP address can change some day if the container is loaded after another.


    the MACVLAN config is set to (IP example):

    Subnet - 192.168.90.0/24

    Gateway - 192.168.90.1

    IpRange - 192.168.90.32/27 (I set this to avoid conflicts to other machines).


    How can I configure it to ask the IP address from my router DHCP server ? This way I can control better the access to the application by IP, set DNS on my LAN, etc....


    Thanks.....

  • from docker documentation:


    https://docs.docker.com/network/macvlan/


  • I've already came on that page, and it does not show hw to configure the interface to use DHCP from my router. I prefer use Portainer if possible. All this configuration explained is possible from web interface and that's what I did.


    My container is getting the IP configured in the range I specified. And I cannot change it.


    Sorry, but althroug I am advanced on Linux, I'm very new on Docker.


    UPDATE: If I try to not define a IPRANGE to the container, it assumes all subnet as the range and applies OMV IP address to it, regardless the configuration I set in exclude-its. seems it's being ignored. So, it is not being asking DHCP, Docker is auto assigning the ip to it.

  • I was searching a lot about that, but found some solutions I cannot implement now, or could not now how to do this, like install ipam-driver for macvlan.


    An easy solution seems to put a static IP address to the container by passing the parameter --ip="xxx.xxx.xxx.xxx" to docker run command. But how do I do that ? where the launch config files are located, so I can edit then and add this parameter ?



    UPDATE: It was so easy.. but since I'm new on this world, never saw the option. There's a BUTTON on top left (portrainer) to edit the Container, it's called Duplicate/Edit. And from there we can edit the container (thing I was missing). Also, on this editing/creating a new one I have the option to set the IP address. It worked.

    • Offizieller Beitrag

    Is a very specific on why containers might require an ip on the same local bridge Subnet, but really all of them ?. Is this because you want web access to all of them on port 80 so you don’t have to type the port?


    If this the case you might need to look at a reverse proxy usage like traefik or nginx without the need to use an exclusive lan ip on all of them.

  • Is a very specific on why containers might require an ip on the same local bridge Subnet, but really all of them ?. Is this because you want web access to all of them on port 80 so you don’t have to type the port?


    If this the case you might need to look at a reverse proxy usage like traefik or nginx without the need to use an exclusive lan ip on all of them.

    What other Way I can access te services installed on each container ? Let's say, if I install a Pi-Hole container, I have to configure all my network to access that container DNS service. It needs a static known IP. If I have another service with a specific web server, not necessarily on port 80, how can access it if it does not have the IP static ?

    • Offizieller Beitrag

    From what i understand pi-hole could need the macvlan, other services like web can be accessed through a hostname domain.


    Traefik usually sits on front of the host in port 80 and 443 and listens to incoming connection, according to hostname required it will route internally (in the docker network) to each service, you won't see the port traefik will handle that automatically


    i type http://plex.ars.com and traefik will fwd to internal docker ip let's say 172.18.0.20:32400/web, doesn't have to plex.ars.com could even be just plain http://plex


    the domains of course have to resolve in the local network either using hosts file or dns server.


    to configure each container to be "adopted" by traefik labels are used that have specific traefik parameters.

  • But I want that each container has it's own real fixed IP address, given by my router DHCP.

    there's no such thing as "fixed ip address given by DHCP". either you have a fixed ip address (set in the container itself or in your router bound to the virtual MAC address of the container) or you have an address assigned by DHCP - which then may change if you restart your container, or router.



    UPDATE: It was so easy.. but since I'm new on this world, never saw the option. There's a BUTTON on top left (portrainer) to edit the Container, it's called Duplicate/Edit. And from there we can edit the container (thing I was missing). Also, on this editing/creating a new one I have the option to set the IP address. It worked.

    even easier if you use docker-compose. certainly for future deployments of the container

    SuperMicro CSE-825, X11SSH-F, Xeon E3-1240v6, 32 GB ECC RAM, LSI 9211-8i HBA controller, 2x 8 TB, 1x 4 TB, 1x3TB, MergerFS+SnapRAID

    Powered by Proxmox VE

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!