Part 1: Installing Containerlab

containerlab
workshop
Install Docker and Containerlab on an Ubuntu host, check that it works, and run a first two-node lab.
Author

Abid Ghufran

Published

November 7, 2026

Containerlab builds network labs out of containers. You describe the routers, switches and hosts and the links between them in one YAML file. Containerlab starts the nodes, wires them together and gives each one a management address. One command brings the lab up, and one takes it down.

This is the first part of the Containerlab workshop. All the instructions are for Ubuntu Linux (22.04, 24.04 or 26.04 LTS, desktop or server). By the end of it you will have:

What you need

Item Requirement
Host An Ubuntu 22.04, 24.04 or 26.04 LTS machine or VM. Use x86_64: many network OS images, Cisco XRd among them, are not built for ARM64
Access A user with sudo rights
CPU More than 1 vCPU. Most network OS containers need at least one core each while booting
Memory Depends on the lab. A Linux node needs a few MB; a Cisco XRd router about 1.6 GB in the labs of this workshop, and up to 2.5 GB when it runs routing protocols
Router image Parts 2 to 5 use Cisco XRd, which you get from Cisco with your own account (Part 2 shows how). Part 1 needs no vendor image
IPv6 Must not be disabled in the kernel
Internet To download packages and container images

For this workshop, a host with 4 vCPUs and 16 GB of RAM is enough for every lab.

NoteHow big a lab can one host run?

On a mini PC with a Ryzen 7 255 and 64 GB of RAM, a 15-router Cisco XRd lab uses about 34 GB of memory and runs comfortably. Memory, not CPU, is usually what limits how many nodes fit on one host.

Before you start

Install curl and git, which the steps below use. Ubuntu Server usually has them; Ubuntu Desktop may not:

sudo apt update
sudo apt install -y curl git

Then choose one of the two options below.

Option A: the quick setup script

On a fresh Ubuntu 22.04 or 24.04 host, one command installs everything: Docker CE, Docker Compose, Containerlab and the GitHub gh CLI.

curl -sL https://containerlab.dev/setup | sudo -E bash -s "all"

The script also raises the SSH server’s maximum login attempts, which helps when you SSH into many lab nodes. To skip that change, run export SETUP_SSHD="false" first.

Important

Log out and back in now. Your user’s new groups (docker and clab_admins) only apply to a new login session. Until then, docker ps fails with permission denied. After logging back in, run id -nG: the output must list both docker and clab_admins. If it does not, reboot.

Then go to Check the installation.

The script is tested on Ubuntu up to 24.04. On Ubuntu 26.04, use Option B.

Option B: step by step

These steps work on every supported Ubuntu release, and are the ones used on the workshop host (Ubuntu 26.04). Each step shows what is being installed, so use this route if you want to know exactly what changed on your system.

1. Install Docker

Ubuntu’s own docker.io package is enough for Containerlab:

sudo apt install -y docker.io
sudo usermod -aG docker "$USER"

The last command lets your user run docker without sudo. If you prefer Docker’s own packages (docker-ce), follow Docker’s install guide instead; either works.

2. Add the Containerlab package repository and install

Containerlab is published in its own APT repository:

echo "deb [trusted=yes] https://netdevops.fury.site/apt/ /" | \
  sudo tee /etc/apt/sources.list.d/netdevops.list

sudo apt update
sudo apt install -y containerlab

Installing from the repository means later upgrades arrive with your normal apt upgrade.

3. Log out and back in

The installer adds your user to a group called clab_admins, and step 1 added you to docker. New group memberships only apply to new login sessions, so log out and log back in.

WarningStill missing the groups after logging back in?

On a desktop session, background user services can survive a logout and keep the old group list. If id -nG still does not show docker and clab_admins after logging back in, reboot the host.

Check the installation

containerlab version
id -nG
docker ps

You should see:

  • a version banner from containerlab version (0.82 or newer at the time of writing)
  • docker and clab_admins in the output of id -nG
  • an empty table from docker ps, not a “permission denied” error
TipWhy no sudo?

Containerlab is installed as a root-owned SUID binary. Members of clab_admins can run commands that change the host, such as deploy and destroy. Everyone else can only run read-only commands such as inspect. Membership is effectively root access to the host, so add only people you trust.

Run a first lab

The workshop repository has a two-node lab to prove that everything works: two small Alpine Linux containers joined by one link.

name: first-lab

topology:
  nodes:
    n1:
      kind: linux
      image: alpine:3
      exec:
        - ip addr add 10.0.12.1/30 dev eth1
    n2:
      kind: linux
      image: alpine:3
      exec:
        - ip addr add 10.0.12.2/30 dev eth1

  links:
    - endpoints: ["n1:eth1", "n2:eth1"]

To see this lab drawn as a diagram, open it in the topology viewer. You can paste any topology file there; it is read in your browser and nothing is uploaded.

Deploy

Get the workshop files into your home folder, then deploy the lab. Every later part uses this same copy, in ~/dynanet-dev:

cd ~
git clone https://github.com/aghufran/dynanet-dev.git
cd ~/dynanet-dev/clab-workshop/labs/01-first-lab
containerlab deploy -t first-lab.clab.yml

Containerlab pulls the Alpine image, starts both nodes, creates the link and prints a table of the nodes with their management addresses. Each node is a container named clab-<lab name>-<node name>.

Verify

Run each check from the host. Each node is a container, so docker exec runs a command inside it.

Step Command You should see
1. Nodes running containerlab inspect --all clab-first-lab-n1 and clab-first-lab-n2, both running
2. Address on n1 docker exec clab-first-lab-n1 ip -4 addr show eth1 inet 10.0.12.1/30
3. Address on n2 docker exec clab-first-lab-n2 ip -4 addr show eth1 inet 10.0.12.2/30
4. Reachability docker exec clab-first-lab-n1 ping -c 3 10.0.12.2 3 packets transmitted, 3 packets received, 0% packet loss

Or run all the checks at once from the lab folder:

./verify.sh
Checking lab first-lab
  PASS  n1 is running
  PASS  n1 eth1 has 10.0.12.1/30
  PASS  n2 is running
  PASS  n2 eth1 has 10.0.12.2/30
  PASS  n1 pings n2 (10.0.12.1 -> 10.0.12.2), 0% loss

All checks passed.

Any FAIL line says which check failed. If every check passes, Containerlab is installed and working.

Verify from inside a node

The checks above run from the host. You can also run them from inside a node, the way you would on a real device. Open a shell in n1:

docker exec -it clab-first-lab-n1 sh

The prompt changes to / #, which means you are now inside n1. The two commands below do the same as steps 2 and 4 in the table above, but you type them here, inside n1, instead of through docker exec from the host. Do not use the docker exec commands from the table now:

Step Command (inside n1) You should see
2. Address on n1 ip -4 addr show eth1 inet 10.0.12.1/30
4. Reachability ping -c 3 10.0.12.2 3 packets transmitted, 3 packets received, 0% packet loss

Type exit to go back to the host.

Now do the same checks from inside n2. Open a shell in it:

docker exec -it clab-first-lab-n2 sh
Step Command (inside n2) You should see
3. Address on n2 ip -4 addr show eth1 inet 10.0.12.2/30
4. Reachability ping -c 3 10.0.12.1 3 packets transmitted, 3 packets received, 0% packet loss

Type exit to go back to the host.

Remove the lab

containerlab destroy -t first-lab.clab.yml

destroy removes the containers and the link. The folder clab-first-lab/ next to the topology file holds the lab’s generated files and is left in place; it is recreated on the next deploy.

Upgrade, pin a version or uninstall

Task Command
Upgrade to the latest release sudo -E containerlab version upgrade, or sudo apt update && sudo apt install containerlab
List the versions available apt-cache madison containerlab
Install a specific version sudo apt install containerlab=0.82.0 (if a newer version is installed, apt asks you to confirm the downgrade)
Stop it upgrading (and allow again) sudo apt-mark hold containerlab (sudo apt-mark unhold containerlab)
Uninstall sudo apt remove containerlab

Everyone in a workshop should run the same Containerlab version, so install the same version on every host and hold it.

Troubleshooting

Symptom Fix
permission denied ... /var/run/docker.sock Your user is not in the docker group yet. Run sudo usermod -aG docker $USER, then log out and in (or reboot)
containerlab deploy asks for root or refuses to run Your user is not in clab_admins yet. Run sudo usermod -aG clab_admins $USER, then log out and in
id -nG still shows the old groups Reboot. A background user session kept the old list
apt cannot find containerlab Check /etc/apt/sources.list.d/netdevops.list exists, then run sudo apt update
Deploy fails with errors that mention IPv6 IPv6 is disabled in the kernel (for example ipv6.disable=1 on the kernel command line). Re-enable it; Containerlab expects it
Image pull fails Check the host’s internet access and DNS. Behind a proxy, configure Docker’s proxy settings

Next

Part 2 covers loading network operating system images, such as Cisco XRd and Arista cEOS, into Docker so that Containerlab can use them.

Sources: Containerlab installation guide · Containerlab quick start

Comments

Comments are reviewed before they appear.