Docker version 28.2.2, build 28.2.2-0ubuntu1~24.04.1
I’ve been following the steps for macvlan in the documentation, but I fear I must be missing something obvious. I need help debugging this.
My goal is to use Compose to have a typical service of containers on their own net but with one container exposing a LAN IP address – which is why I included compose in the category. But, baby steps…
I have simple container called ub-net:
$ cat Dockerfile
FROM ubuntu:latest
RUN apt update
RUN apt install iproute2 iputils-ping ncat -y
CMD ["sleep","infinity"]
This works, of course:
docker run --rm -it --sysctl net.ipv6.conf.all.disable_ipv6=1--name=foo ub-net:latest ping google.com
PING google.com (142.250.72.142) 56(84) bytes of data.
64 bytes from lax17s49-in-f14.1e100.net (142.250.72.142): icmp_seq=1 ttl=113 time=18.8 ms
My host’s interface and IP:
$ ip route | grep default
default via 192.168.0.1 dev wlp3s0 proto dhcp src 192.168.0.253 metric 600
Update: Forgot to mention I also tried promiscuous mode on the host interface:
$ sudo ip link set dev wlp3s0 promisc on
Now, create a macvlan network and try again:
$ docker network create -d macvlan \
--subnet=192.168.0.0/24 \
--gateway=192.168.0.1 \
-o parent=wlp3s0 \
test_macvlan
ad660efe198ed1d1020c7138f8024a7fe03e60506b73da5357ad581cad2b53cc
This looks as expected, correct?
$ docker run --rm -it \
--sysctl net.ipv6.conf.all.disable_ipv6=1 \
--network test_macvlan \
--ip 192.168.0.250 \
--name foo ub-net:latest \
ip -br route
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.250
But, nothing getting out:
$ docker run --rm -it \
--sysctl net.ipv6.conf.all.disable_ipv6=1 \
--network test_macvlan \
--ip 192.168.0.250 \
--name foo ub-net:latest \
ping google.com
PING google.com (142.250.72.142) 56(84) bytes of data.
From 3f9f5a02a746 (192.168.0.250) icmp_seq=11 Destination Host Unreachable
And I cannot ping 192.168.0.250 from another host on my LAN. Here’s from my Mac laptop:
$ ping 192.168.0.250
PING 192.168.0.250 (192.168.0.250): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Here's the docker-compose.yaml I first tried to use:
$ cat docker-compose.yaml
name: My Test
services:
test_one:
image: ub-net:latest
container_name: testone
hostname: host-testone
networks:
mylocal: {}
my_macvlan: {}
# ip4_address: 192.168.0.210
# mac_address: "16:50:8c:86:0a:35"
cap_add:
- NET_ADMIN
test_two:
image: ub-net:latest
container_name: testtwo
hostname: host-testtwo
networks:
mylocal: {}
networks:
mylocal:
name: mytest_default
external: true
my_macvlan:
name: test_macvlan
external: true
I’ve seen different examples of how to specify the IP address.
Using this:
networks:
mylocal: {}
my_macvlan:
ip4_address: 192.168.0.210
generates:
$ docker compose up -d
validating /home/bill/macvlan/docker-compose.yaml: services.test_one.networks.my_macvlan Additional property ip4_address is not allowed