VPP Containerlab Docker image
This docker container creates a VPP instance based on the latest release. It starts up as per normal, using /etc/vpp/startup.conf (which Containerlab will replace), and once started, it'll execute /etc/vpp/bootstrap.vpp within the dataplane. There are three relevant files:
-
manual-pre.vpp
-- can be supplied by the user, to run any configuration statements before containerlab takes control. -
clab.vpp
-- generated by containerlab. Its purpose is to bind thevethpair
interfaces into theo dataplane (see below). -
manual-post.vpp
-- can be supplied by the user, to run any configuration statements after containerlab is finished with its per-lab statements.
Building
docker build --no-cache -f Dockerfile.bookworm . -t pimvanpelt/vpp-containerlab
Starting the container
docker network create --driver=bridge network2 --subnet=172.19.1.0/24
docker rm clab-pim
docker run --cap-add=NET_ADMIN --cap-add=SYS_NICE --cap-add=SYS_PTRACE \
--device=/dev/net/tun:/dev/net/tun \
--device=/dev/vhost-net:/dev/vhost-net \
--privileged=True --name clab-pim \
docker.io/pimvanpelt/vpp-containerlab
docker network connect network2 clab-pim
A note on DPDK
DPDK will be disabled by default as it requires hugepages and VFIO and/or UIO to use physical network cards. If DPDK at some future point is desired, mapping VFIO can be done by adding this:
--device=/dev/vfio/vfio:/dev/vfio/vfio
or in Containerlab, using the devices
feature:
my-node:
image: vpp-containerlab:latest
kind: vpp
devices:
- /dev/vfio/vfio
- /dev/net/tun
- /dev/vhost-net
If using DPDK in a container, one of the userspace IO kernel drivers must be loaded in the host
kernel. Options are igb_uio
, vfio_pci
, or uio_pci_generic
:
$ sudo modprobe igb_uio
$ sudo modprobe vfio_pci
$ sudo modprobe uio_pci_generic
Particularly the VFIO driver needs to be present before one can attempt to bindmount
/dev/vfio/vfio
into the container!
Configuring VPP
When Containerlab starts the docker containers, it'll offer one or more vethpair
point to point
network links, which will show up as eth1
and further. eth0
is the default NIC that belongs to
the management plane in Containerlab (the one which you'll see with containerlab inspect
). Before
VPP can use these vethpair
interfaces, it needs to bind them, like so:
docker exec -it clab-pim vppctl
and then within the VPP control shell:
create host-interface v2 name eth1
set interface name host-eth1 eth1
set interface mtu 1500 eth1
set interface ip address eth1 172.19.1.2/24
set interface ip address eth1 fec0::2/64
set interface state eth1 up
Containerlab will generate a config file called /etc/vpp/clab.vpp
which contains all of these
comands. You can add more commands that'll execute on startup by copying in
/etc/vpp/manual-pre.vpp
(to be executed before the containerlab stuff) or
/etc/vpp/manual-post.vpp
(to be executed after the containerlab stuff).