Assign multiple IPs to same docker container using macvlan (or by any other method)

Tags: #<Tag:0x00007f326ea14f58>

Hi All,
Not related to HA but I know this community is full of experts. So worth to ask.
I have currently 2 networks created using macvlan running over my synology. These networks are physically seprated and completely isolated. So device on one network can not communicate to other.

    [email protected]:/# docker network ls
    NETWORK ID      NAME               DRIVER              SCOPE
    12434567        priNet             macvlan             local
    76543210        secNet             macvlan             local

I am using these networks as my primary home network and other for my smart home devices. I am able to attach any docker container to any of them. However, now I would like to attach some containers to both of them.
So I updated my docker-compose to attach container to both networks.

    version: "3.7"
        image: someImage:latest
          TZ: 'Europe/Berlin'
           - /etc/localtime:/etc/localtime:ro
        restart: always
        external: true
        name: priNet
        external: true
        name: secNet

After running this docker compose file, I get following error

level=fatal msg=\\\\\\\"failed to add interface dockerb21a0fc to sandbox: error setting interface \\\\\\\\\\\\\\\"dockerb21a0fc\\\\\\\\\\\\\\\" IP to cannot program address in sandbox interface because it conflicts with existing route {Ifindex: 194 Dst: Src: Gw: <nil> Flags: [] Table: 254}\\\\\\\"\\\\n\\\"\"": unknown

Do you think if what I am doing is right way to do it ? Or is it even technically possible ? I am also fine to achive same thing by some other way…

Many thanks for your all of your suggestions…

Try to set address spaces used in your networks explicitly with “subnet” clause in “networks” section

many thanks for your reply. (Your first post, and first response to query !!!
Do you mind to put an example. I tried some and it did failed.