DEV Community

Discussion on: Make Docker containers available both on your local network with Macvlan and on the web with Traefik

Collapse
 
mexhigh profile image
Leon Schmidt

Thanks for your contribution. Maybe something that is interesting too: If you want to add a static mac address to the macvlan container, you can do so with this configuration:

version: '2.4'
services:
  some_service:
    image: some_image
    mac_address: 02:42:C0:A8:69:AC
    networks:
      lan:
        ipv4_address: 192.168.1.155
        priority: 1000
      web:
...
Enter fullscreen mode Exit fullscreen mode

The priority directive is only available in docker-compose file version 2, sadly. This prioritizes the macvlan network, as the mac address is only assigned to one of the network interfaces. Without the priority the mac address might be assigned to the web nic. The default priority is 0.