# Docker

# Create a MAC VLAN network

##### Description

The command below is an example of creating a layer 2 macvlan network in docker. In the example below, the network I am using is 10.128.140.0/24 on interface ens160. You will have to replace the subnet and interface according to your install.

##### Conifguration

> <span class="s1">docker network create -d macvlan --subnet=10.128.140.0/24 --gateway 10.128.140.1 -o parent=ens160 L2-Connect</span>

<span class="s1">and this is how you add a VLAN network</span>

> docker network create -d macvlan --subnet=172.16.8.0/22 --gateway 172.16.8.1 -o parent=ens192.40 Data-40-L2-Connect

<span class="s1">After creation of the network you can take a look to make sure it exists</span>

> <span class="s1">root@container:~# docker network ls</span>
> 
> <span class="s1">NETWORK ID <span class="Apple-converted-space"> </span>NAME <span class="Apple-converted-space"> </span>DRIVER<span class="Apple-converted-space"> </span>SCOPE</span>
> 
> <span class="s1">01734d37ed78 <span class="Apple-converted-space"> </span>L2-Connect <span class="Apple-converted-space"> </span>macvlan <span class="Apple-converted-space"> </span>local</span>
> 
> <span class="s1">310563fabcd7 <span class="Apple-converted-space"> </span>bridge <span class="Apple-converted-space"> </span>bridge<span class="Apple-converted-space"> </span>local</span>
> 
> <span class="s1">4bc024cbd7cc <span class="Apple-converted-space"> </span>host <span class="Apple-converted-space"> </span>host<span class="Apple-converted-space"> </span>local</span>
> 
> <span class="s1">d2879a267450 <span class="Apple-converted-space"> </span>none <span class="Apple-converted-space"> </span>null<span class="Apple-converted-space"> </span>local</span>

# Deploy Portainer on a MAC VLAN network

##### Description

On the previous page I showed how to create a layer 2 macvlan network that allows you to deploye containers in the same network as the host itself. This example will show you how to deploye Portainer CE using the layer 2 macvlan network we created.

##### Configuration

> <span class="s1">root@container:~# docker run -d --network L2-Connect --ip=10.128.140.31 --dns=1.1.1.1 --name=Portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer\_data:/data portainer/portainer-ce:latest</span>

<span class="s1">Once the container has been created you can run the docker container ls command to see the deployed container.</span>

> <span class="s1">root@container:~# docker container ls</span>
> 
> <span class="s1">CONTAINER ID <span class="Apple-converted-space"> </span>IMAGE <span class="Apple-converted-space"> </span>COMMAND<span class="Apple-converted-space"> </span>CREATED<span class="Apple-converted-space"> </span>STATUS<span class="Apple-converted-space"> </span>PORTS <span class="Apple-converted-space"> </span>NAMES</span>
> 
> <span class="s1">cd30907cabe6 <span class="Apple-converted-space"> </span>portainer/portainer-ce:latest <span class="Apple-converted-space"> </span>"/portainer" <span class="Apple-converted-space"> </span>10 minutes ago <span class="Apple-converted-space"> </span>Up 10 minutes <span class="Apple-converted-space"> </span>Portainer</span>