Static IPs for containers

I created a Pi-Hole container with Docker Compose. Unfortunately, it’s on a different subnet and I can’t set it up locally. Since I would be using this for DNS, it needs to be static. I read some posts and I remember using Mcvlan previously years ago.

I found this:

docker network create -d macvlan \
  --subnet=192.168.32.0/24 \
  --ip-range=192.168.32.128/25 \
  --gateway=192.168.32.254 \
  --aux-address="my-router=192.168.32.129" \
  -o parent=eth0 macnet32

I didn’t see what each option does, specifically, --ip-range, --aux-address (guessing that;s the IP for my local router) and -o parent. My router and gateway are the same, so would I need both those options?

Is this still the way to do things or is there a way to add something in the docker-compose.yml file?

TIA

Just to be sure: you want the container to run in your local network, so other clients in your network can reach it directly? And you don’t want it be the ip of your docker host.

We had a couple of mavlan topics over the years, so forum search should yield some useful posts.

Docker is good documented, so in case you are looking for something, it is usally a good idea to google for docker and the subject you are looking for, e.g. I googled “docker macvlan” for you and the first result for me is https://docs.docker.com/engine/network/drivers/macvlan/.

I have it working. Lots of bad info out there. Not really bad, just probably old.

Thanks!!

Now I am curious: How did you solve it at the end? Following the suggestion from the Pi-Hole docs? Or did you still go down the macvlan route?