On network creation, the user can specify which IPAM driver libnetwork needs to use for the network’s IP address management.
#Docker network subnet drivers
Libnetwork has a default, built-in IPAM driver and allows third party IPAM drivers to be dynamically plugged. Remember: Docker controls the IP address assignment for network and endpoint interfaces via the IPAM driver(s). In this case you should configure the IP address only so your containers get the same IP addresses as described here. You don’t need to configure the IPv4 and IPv6 address – Docker’s IPAM driver can assign an IP address from the network’s subnet automatically. Select the image of your choice or just use phusion/baseimage for the purpose of this tutorial: docker run \ Spin up container0 and container2, each connected to its own macvlan network. Notice the parent interface and IP configurations: # docker network inspect macvlan10 Inspect one of the newly created macvlan networks. Verify that the macvlan networks were created: # docker network ls Notice that sub interface number matches the VLAN tag/id: # ip -d addr show | grep 'mtu\|vlan'Ģ9: : mtu 1500 qdisc noqueue state UP group defaultģ3: : mtu 1500 qdisc noqueue state UP group default macvlan20 network uses sub interface eth0.20.ĭocker macvlan driver automagically creates host sub interfaces when you create a new macvlan network with sub interface as a parent. Macvlan10 network uses sub interface eth0.10 as a parent. Verify which interfaces are available on the Docker host: # ip addr | grep mtuĢ: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000Ĭreate two macvlan networks, one for each VLAN: docker network create -d macvlan 1Q configuration, there is no need to learn about it now – it will be taken care of by Docker’s macvlan driver. Docker will use your existent VLAN configuration, just make sure your sub interface numbers match the VLAN tags. 1Q sub interfaces already configured on your Docker host. All containers are dual-stack, running both IPv4 and IPv6. container1 will have two interfaces, one in each VLAN. You need to connect container0 to VLAN 10 and container2 to VLAN 20.
#Docker network subnet how to
… else I’m sure you know how to configure it on your router. Switch(config-if)# switchport trunk native vlan 1 Switch(config)# interface fastEthernet0/0 …or Cisco Layer 3 Switch… switch# configure terminal Router(config-subif)# encapsulation dot1Q 20 Router(config)# interface fastEthernet 0/0.20 Router(config-subif)# encapsulation dot1Q 10 Router(config)# interface fastEthernet 0/0.10 Here’s the configuration if you happen to have a Cisco IOS router… router(config)# interface fastEthernet 0/0 Connection between the router and the Docker host is configured as 802.1Q trunk on the router with VLAN 10 and VLAN 20.Ĭonfigure VLAN 10 and VLAN 20 on your router. You have a Docker host with a single eth0 interface connected to a router. Multiple macvlans with VLANs configuration You can map each Docker host interface to a macvlan network, thus extending the Layer 2 domain from the VLAN into the macvlan network. This aligns perfectly with the Linux implementation of VLANs, where each VLAN on a 802.1Q trunk connection is terminated on a sub-interface of the physical interface. Fortunately, a Docker host sub-interface can serve as a parent interface for the macvlan network. One macvlan, one Layer 2 domain and one subnet per physical interface, however, is a rather serious limitation in a modern virtualization solution. If you have read my introduction to macvlans and tried the basic macvlan bridge mode network configuration you are aware that a single Docker host network interface can serve as a parent interface to one macvlan or ipvlan network only.