✦ For everyone, free.

Practical knowledge for real and everyday life

Home

7.2.5 Macvlan Driver

A focused guide to Macvlan Driver, connecting core concepts with practical Docker and container operations.

The macvlan network driver assigns a container its own MAC address, making it appear on the physical network as a distinct, directly addressable device, rather than being hidden behind the host's own network identity the way standard bridge networking is.

Creating a Macvlan Network

A macvlan network is configured against a specific physical network interface on the host, which the resulting containers will appear to be directly connected to.

docker network create -d macvlan \
  --subnet=192.168.1.0/24 \
  --gateway=192.168.1.1 \
  -o parent=eth0 \
  macvlan-net
Running a Container on a Macvlan Network

A container attached to this network receives its own MAC address and IP address from the configured subnet, appearing on the physical network as its own distinct device.

docker run -d --network macvlan-net --ip=192.168.1.50 myapp:1.0

Devices on the same physical network see this container as a genuinely separate device with its own MAC and IP, rather than as traffic originating from behind the host's own network identity.

Why This Driver Suits Specific Legacy or Specialized Needs

Certain legacy applications, or networking configurations requiring each workload to appear as its own discrete device on the physical network (for compliance, monitoring, or compatibility reasons), specifically benefit from this driver's direct network presence.

docker run -d --network macvlan-net --ip=192.168.1.51 legacy-network-appliance:1.0
Why This Driver Is Less Commonly Needed

For the large majority of containerized applications, standard bridge networking (with NAT and port publishing as needed) is simpler to configure and sufficient — macvlan is reserved for the narrower set of cases specifically requiring this direct physical network presence.

docker run -d -p 8080:80 nginx:alpine
Why the Macvlan Driver Matters

Macvlan addresses a specific, less common networking requirement — direct physical network presence for individual containers — providing a capability standard bridge networking cannot offer, at the cost of requiring more careful, host-network-aware configuration.

Content in this section