User Tools

Site Tools


docker:network:macvlan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docker:network:macvlan [2025/11/24 15:32] – created jonathandocker:network:macvlan [2025/11/24 19:20] (current) jonathan
Line 35: Line 35:
 docker run --rm -it --name alpine --network vlan100-ipv4 --network vlan100-ipv6 alpine ping 8.8.8.8 docker run --rm -it --name alpine --network vlan100-ipv4 --network vlan100-ipv6 alpine ping 8.8.8.8
 docker run --rm -it --name alpine --network vlan100-ipv4 --network vlan100-ipv6 alpine ping ipv6.google.com docker run --rm -it --name alpine --network vlan100-ipv4 --network vlan100-ipv6 alpine ping ipv6.google.com
 +</code>
 +
 +
 +
 +<code -- docker-compose format>
 +services:
 +  alpine:
 +    image: alpine
 +    stdin_open: true
 +    tty: true
 +    cap_add:
 +      - NET_ADMIN
 +    command: ["sh", "-c", "ip route replace default via 192.168.222.1 dev eth1 && sh"]
 +    networks:
 +      vlan100-ipv4:
 +        ipv4_address: 192.168.222.200
 +      vlan100-ipv6:
 +        ipv6_address: 2001:db8:1d:2ec::200
 +
 +networks:
 +  vlan100-ipv4:
 +    external: true
 +
 +  vlan100-ipv6:
 +    external: true
 +
 +</code>
 +
 +
 +
 +<note warning>IP assignment doesn't work with docker run</note>
 +
 +
 +<code -- IP assignment doesn't work with docker run>
 +root@ucpe2:~/test# docker run -it --rm \
 +  --name alpine \
 +  --cap-add=NET_ADMIN \
 +  --network vlan100-ipv4 --ip 192.168.222.200 \
 +  --network vlan100-ipv6 --ip6 2001:db8:1d:2ec::200 \
 +  alpine \
 +  sh -c "ip route replace default via 192.168.222.1 dev eth1 && sh"
 +docker: Error response from daemon: invalid config for network vlan100-ipv4: invalid endpoint settings:
 +user specified IP address is supported only when connecting to networks with user configured subnets
 </code> </code>
  
docker/network/macvlan.1763998377.txt.gz · Last modified: by jonathan