summaryrefslogtreecommitdiff
path: root/docs/installation/virtual/docker.md
blob: 6d9800662afbdcfd9dafbdf1b2e21d51e0b93d23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
lastproofread: '2026-08-30'
---

(docker)=

# Run VyOS as a container

Docker is an open-source project for deploying applications as standardized
units called containers. Deploying VyOS in a container provides a simple and
lightweight mechanism for both testing and packet routing for container
workloads.

## IPv6 support for Docker

VyOS requires an IPv6-enabled Docker network. Currently Linux distributions
do not enable Docker IPv6 support by default.

You can enable IPv6 support in two ways.

### Method 1: Create a docker network with IPv6 support

Here's an example using the `macvlan` driver.

```none
docker network create --ipv6 -d macvlan -o parent=eth0 --subnet 2001:db8::/64 --subnet 192.0.2.0/24 mynet
```

### Method 2: Add IPv6 support to the Docker daemon

Edit /etc/docker/daemon.json to set the `ipv6` key to `true` and specify
the `fixed-cidr-v6` to your desired IPv6 subnet.

```none
{
  "ipv6": true,
  "fixed-cidr-v6": "2001:db8::/64"
}
```

Reload the Docker configuration.

```none
$ sudo systemctl reload docker
```


## Deploy container from ISO

A VyOS ISO image can be converted into an OCI (Open Container Initiative)
image using the `iso-to-oci` helper script from the
[vyos-build](https://github.com/vyos/vyos-build) repository. The script
extracts the root filesystem from the ISO, removes components which are not
usable inside a container (kernel, firmware, and the corresponding CLI nodes),
and generates a tarball which can be imported by Docker.

The script requires `xorriso`, `squashfs-tools` and `jq` to be installed. All
of them are already present in the vyos-build container.

### Build a container image from a locally built ISO

If you build your own ISO from source (see {ref}`build`), the `oci` make
target converts the ISO which is generated in `build/` in one step:

```none
$ make oci
I: extracting ISO metadata
I: extracting squashfs image
I: extracting squashfs content
I: generate OCI container image vyos-1.5.1-oci-amd64.tar
I: to import the previously generated OCI image to your local images run:

   docker import vyos-1.5.1-oci-amd64.tar vyos:1.5.1 --change 'CMD ["/sbin/init"]'
```

### Build a container image from a downloaded ISO

To use a released or nightly ISO instead, call the script directly and pass
the path to the ISO image:

```none
$ git clone https://github.com/vyos/vyos-build.git
$ ./vyos-build/scripts/iso-to-oci vyos-1.5.1-generic-amd64.iso
```

### Import and run the container

Import the generated tarball as a local image and start the container. If you
created a custom IPv6-enabled network, include it as the `--net` parameter to
`docker run`.

```none
$ docker import vyos-1.5.1-oci-amd64.tar vyos:1.5.1 \
> --change 'CMD ["/sbin/init"]'
$ docker run -d --rm --name vyos --privileged -v /lib/modules:/lib/modules \
> vyos:1.5.1
$ docker exec -ti vyos su - vyos
```

To stop the container, run `docker stop vyos`.

:::{hint}
The very same image can also be used with
[Containerlab](https://containerlab.dev) to build virtual network labs. Refer
to its [VyOS kind](https://containerlab.dev/manual/kinds/vyosnetworks_vyos/)
documentation for the required node settings.
:::