Setup MacvLAN on docker instance

After you created a docker instance, by default it will sharing the docker host default network interface IP address and port.

If you want to create a virtual LAN for docker and getting static dedicated IP address from the same network as the host, you will need to setup a MacVLAN under the docker.

Simply use the below command to create a MacVLAN. But first, you will need to identify your host network interface, IP range, subnet and the DHCP configuration to avoid IP conflict.

sudo docker network create -d macvlan -o -parent=eth0 --subnet=192.168.81.0/24 --gateway=192.168.81.1 --ip-range=192.168.81.8/32 new-macvlan

The next step is to create a bridge interface on the docker, you use any network which is not in use.

Finally, add both bridge network and macvlan network to the docker instance to get it work.

Leave a Reply

Your email address will not be published. Required fields are marked *