Giving container its own ip address with docker-compose?

You will have to provide more info to try and figure out what's going on. For example what command did you enter to create your macvlan network? This is mine:

sudo docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 --ip-range=192.168.1.2/28 -o parent=eth1 --aux-address="host=192.168.1.11" macvlan0

This creates a network named macvlan0 that covers ip range 192.168.1.1 through 192.168.1.24 and I then modified the dhcp settings of my router to only assign ip addresses from 192.168.1.128 and above.

The -aux-address is the ip address that is assigned to the pihole container (see ServerIP in docker-compose). Below is my docker-compose:

version: "3"

services: pihole: capadd: - NET_ADMIN container_name: pihole-vlan dns: - 127.0.0.1 - 1.1.1.1 domainname: local.net environment: DHCP_ACTIVE: "true" DHCP_END: 192.168.1.254 DHCP_IPv6: "false" DHCP_LEASETIME: 168 DHCP_ROUTER: 192.168.1.1 DHCP_START: 192.168.1.128 DNSMASQ_LISTENING: local DNSMASQ_USER: root IPv6: "false" PIHOLE_DNS: 1.1.1.1 PIHOLE_DOMAIN: insert your router domain ServerIP: 192.168.1.10 TZ: ${TZ} VIRTUAL_HOST: pihole. WEBPASSWORD: insert your pihole password hostname: pihole.local.net image: pihole/pihole:latest mac_address: de:ad:be:ef:ff:01 networks: macvlan: ipv4_address: 192.168.1.10 ports: - 443/tcp - 53/tcp - 53/udp - 67/udp - 80/tcp - 20/tcp restart: unless-stopped volumes: - /volume1/docker/pihole/volume:/etc/pihole - /volume1/docker/pihole/config/dnsmasq.d:/etc/dnsmasq.d - /volume1/docker/pihole/logs:/var/log networks: macvlan: external: true

/r/docker Thread Parent