Skip to content

[macvlan] Same parent and gateway for multiple networks #2384

@bodji

Description

@bodji

Hi,

We are struggling with an issue with macvlan driver.

We wonder why we can't have multiple macvlan docker network with the same parent ?

This check forbids it in libnetwork/drivers/macvlan/macvlan_network.go :

 func (d *driver) createNetwork(config *configuration) error {
       networkList := d.getNetworks()
       for _, nw := range networkList {
               if config.Parent == nw.config.Parent {
                       return fmt.Errorf("network %s is already using parent interface %s",
                               getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent)
               }
       }

And, also, why we can't have the same gateway for multiple macvlan docker networks ?

// Convert IP ordinal for this subnet into IP address
               return generateAddress(ordinal, base), nil
        case bitseq.ErrBitAllocated:
               return nil, ipamapi.ErrIPAlreadyAllocated

Our use case is the following :

  • 3 dockers nodes in Swarm mode
  • A public /28 RIPE routed to a private virtual network on each node
  • Mount public IP directly in containers

Our problem :

  • We want to specify the public IP of a container.
    -> IPAM in Swarm does not allow to specify ipv4_address param in compose file (normal behaviour with --scale)

    -> So we thought about creating one macvlan network with same parent interface, same gateway, and an --ip-range with the /32 we want.

We made some patch on the two files specified, and it works.

Is it a viable solution, and could we remove safely those checks?

Thank you !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions