IPvlan network driver

Hello,

I’d like to create two networks:

  • the IPvlan network
  • the standart bridge network

and then attach these to a container.

I created below .yaml manifest:

version: '3.8'

services:
  gitea:
    container_name: gitea
    image: gitea/gitea:1.20-rootless
    networks:
      bridge:
        ipv4_address: 192.168.0.2
      ipvlan:
        ipv4_address: 192.168.1.2
    restart: always
    volumes:
    - gitea:/data:Z
    - /etc/timezone:/etc/timezone:ro
    - /etc/localtime:/etc/localtime:ro
    
volumes:
  gitea: {}

networks:
  bridge:
    ipam:
      config:
      - subnet: 192.168.0.0/24
  ipvlan:
    driver: ipvlan
    driver_opts:
      parent: ens33
      ipvlan_mode: l3
    ipam:
      config:
      - subnet: 192.168.1.0/24

and it doesn’t work. I see such output:

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: failed to add interface veth436ff1f to sandbox: error setting interface "veth436ff1f" routes to ["0.0.0.0/0"]: file exists: unknown 

but when I comment out one of the network everything works fine.

Where is the issue? Can someone help me?

I am running into the same error message and issue. I have also someone on reddit that is trying to do the same thing. None of us seem to be able to make this work.
I want a compose stack to create a few DB/backend related containers, and only ONE container have a connection to a IPVLAN L3 network and that same backend network (Total two networks)
I am creating external networks. I have tried one ipvlan and one bridge, and have tried using both networks as ipvlans nothing seems to work.
I have found that if I use lists instead of a mapping (with a defined IP) I do get the stack working, but networking assigns all of the containers to both networks… Even though the only one container has both networks defined.

I tried your compose file and couldn’t make it work. Seem like the ip_range for the ipvlan l3 network must be declared.

With rootful docker and docker compose v2 it works like this:

services:
  gitea:
    container_name: gitea
    image: gitea/gitea:1.20
    networks:
      bridge:
        ipv4_address: 192.168.0.2
      ipvlan:
        ipv4_address: 192.168.1.3
    restart: always
    volumes:
    - gitea:/data
    - /etc/timezone:/etc/timezone:ro
    - /etc/localtime:/etc/localtime:ro

volumes:
  gitea: {}

networks:
  bridge:
    ipam:
      config:
      - subnet: 192.168.0.0/24
  ipvlan:
    driver: ipvlan
    internal: true
    driver_opts:
      ipvlan_mode: l3
    ipam:
      config:
      - subnet: 192.168.1.0/24
        ip_range: 192.168.1.0/27

It doesn’t work for me if the driver_opts.parent is configured or ipam.config[0].ip_range is missing.