In the 802.1Q trunked bridge example, your traffic flows through a sub-interface
of `eth0` (called `eth0.10`) and Docker routes traffic to your container using
its MAC address. To network devices on your network, your container appears to
be physically attached to the network.
1. Create a `macvlan` network called `my-8021q-macvlan-net`. Modify the
`subnet`, `gateway`, and `parent` values to values that make sense in your
environment.
```console
$ docker network create -d macvlan \
--subnet=172.16.86.0/24 \
--gateway=172.16.86.1 \
-o parent=eth0.10 \
my-8021q-macvlan-net
```
You can use `docker network ls` and `docker network inspect my-8021q-macvlan-net`
commands to verify that the network exists, is a `macvlan` network, and
has parent `eth0.10`. You can use `ip addr show` on the Docker host to
verify that the interface `eth0.10` exists and has a separate IP address
2. Start an `alpine` container and attach it to the `my-8021q-macvlan-net`
network. The `-dit` flags start the container in the background but allow
you to attach to it. The `--rm` flag means the container is removed when it
is stopped.
```console
$ docker run --rm -itd \
--network my-8021q-macvlan-net \
--name my-second-macvlan-alpine \
alpine:latest \
ash
```
3. Inspect the `my-second-macvlan-alpine` container and notice the `MacAddress`
key within the `Networks` key:
```console
$ docker container inspect my-second-macvlan-alpine
...truncated...
"Networks": {
"my-8021q-macvlan-net": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"12f5c3c9ba5c"
],
"NetworkID": "c6203997842e654dd5086abb1133b7e6df627784fec063afcbee5893b2bb64db",
"EndpointID": "aa08d9aa2353c68e8d2ae0bf0e11ed426ea31ed0dd71c868d22ed0dcf9fc8ae6",
"Gateway": "172.16.86.1",
"IPAddress": "172.16.86.2",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:10:56:02",
"DriverOpts": null
}
}
...truncated
```
4. Check out how the container sees its own network interfaces by running a
couple of `docker exec` commands.
```console
$ docker exec my-second-macvlan-alpine ip addr show eth0
11: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:10:56:02 brd ff:ff:ff:ff:ff:ff
inet 172.16.86.2/24 brd 172.16.86.255 scope global eth0
valid_lft forever preferred_lft forever
```
```console
$ docker exec my-second-macvlan-alpine ip route
default via 172.16.86.1 dev eth0
172.16.86.0/24 dev eth0 scope link src 172.16.86.2
```
5. Stop the container (Docker removes it because of the `--rm` flag), and remove
the network.
```console
$ docker container stop my-second-macvlan-alpine
$ docker network rm my-8021q-macvlan-net
```
## Other networking tutorials
- [Standalone networking tutorial](/manuals/engine/network/tutorials/standalone.md)
- [Overlay networking tutorial](/manuals/engine/network/tutorials/overlay.md)
- [Host networking tutorial](/manuals/engine/network/tutorials/host.md)