Setting up docker network for Vlans

Setting Up a VLAN and Docker IPvlan Network

This guide demonstrates how to create a VLAN on a host interface and then use it to run a Docker container on a dedicated subnet using the IPvlan driver.

1. Create a VLAN Interface

Explanation:


2. Create a Docker IPvlan Network


docker network create -d ipvlan \ --subnet 10.14.107.0/24 \ --gateway 10.14.107.1 \ -o parent=eth0.107 \ test2 

Explanation:


3. Run a Docker Container on the IPvlan Network


sudo docker run -itd --rm --network test2 --ip 10.14.107.50 --name test2 ubuntu

Explanation:


Result:
You now have a Docker container (test2) running on its own VLAN (eth0.107) with a dedicated subnet. This setup is useful for network isolation, lab testing, or managing multiple services with their own IP addresses.




Revision #2
Created 2025-10-13 01:51:54 UTC by Dale
Updated 2025-10-13 04:07:33 UTC by Dale