containerlab on CentOS 7

Containerlab provides a CLI for orchestrating and managing containerized network labs. It creates the containers and adds virtual wiring between to create topologies defined by the user. Topologies are created with simple YAML files. This article describes how to install and run containerlab on CentOS 7. Containerlab is a great way to fire up network labs super fast and easy. With enough compute resources (containerlab can also run in a multi-node setup) one can simulate even big datacenter networks with ease. This makes it a perfect tool for network teams and individuals to verify configs before pushing them to productive devices, testing new features or to study.

Preparing the system

First, we need to install docker (if there are any other docker versions installed, remove them first):

$ sudo yum -y install yum-utils
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
$ sudo systemctl start docker
$ sudo systemctl enable docker

After that you can test if the installation was successful by running the hello-world docker image:

[superman@clab ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[superman@clab ~]$

Install containerlab

Setting up containerlab is fairly easy, just run bash -c "$(curl -sL https://get.containerlab.dev)"

Run your first lab

To verify that containerlab has been installed correctly, we will create a small lab with 2 nodes (Arista cEOS and Nokia SR Linux).
Arista cEOS has to be manually imported prior to using. Download the latest image here, copy to your lab machine and import with sudo docker import cEOS64-lab-4.29.2F.tar ceos:4.29.2F

Create the topology file

Create a directory structure for your labs (i.e labs/lab1, labs/lab2 etc) and create <name>.clab.yaml

[superman@clab testlab]$ mkdir -p labs/testlab && cd labs/testlab
# EDIT topology file testlab.clab.yaml
[superman@clab testlab]$ cat testlab.clab.yaml
name: testlab
topology:
  nodes:
    srl:
      kind: srl
      image: ghcr.io/nokia/srlinux
    ceos:
      kind: ceos
      image: ceos:4.29.2F
  links:
    - endpoints: ["srl:e1-1", "ceos:eth1"]
[superman@clab testlab]$

Run the lab

[superman@clab testlab]$ sudo clab deploy
[sudo] password for superman:
INFO[0000] Containerlab v0.38.0 started
INFO[0000] Parsing & checking topology file: testlab.clab.yaml
INFO[0000] Creating lab directory: /home/superman/labs/testlab/clab-testlab
INFO[0002] Creating docker network: Name="clab", IPv4Subnet="172.20.20.0/24", IPv6Subnet="2001:172:20:20::/64", MTU="1500"
INFO[0002] Creating container: "srl"
INFO[0002] Creating container: "ceos"
INFO[0003] Creating virtual wire: srl:e1-1 <--> ceos:eth1
INFO[0003] Running postdeploy actions for Nokia SR Linux 'srl' node
INFO[0003] Running postdeploy actions for Arista cEOS 'ceos' node
INFO[0050] Adding containerlab host entries to /etc/hosts file
+---+-------------------+--------------+-----------------------+------+---------+----------------+----------------------+
| # |       Name        | Container ID |         Image         | Kind |  State  |  IPv4 Address  |     IPv6 Address     |
+---+-------------------+--------------+-----------------------+------+---------+----------------+----------------------+
| 1 | clab-testlab-ceos | 35f501519e79 | ceos:4.29.2F          | ceos | running | 172.20.20.2/24 | 2001:172:20:20::2/64 |
| 2 | clab-testlab-srl  | 3b560315e5a0 | ghcr.io/nokia/srlinux | srl  | running | 172.20.20.3/24 | 2001:172:20:20::3/64 |
+---+-------------------+--------------+-----------------------+------+---------+----------------+----------------------+
[superman@clab testlab]$

You can now connect to the boxes either via SSH or via docker exec command.

Leave a Reply

Cookie Consent Banner by Real Cookie Banner