containerlab β spin up containerized network labs
Define multi-vendor network topologies as simple YAML and deploy them in seconds with Docker. Perfect for testing automation, learning protocols and running labs in CI.
Detailed setup
Prerequisites
- A Linux host or VM (Ubuntu/Debian/RHEL) β or WSL2 / a Linux VM on Windows & macOS.
- Docker Engine 20.10+ installed and running, with your user in the docker group.
- x86_64/amd64 CPU, 2+ vCPU and 4 GB+ RAM (more for multi-node or cEOS labs).
- Outbound internet access to pull the clab binary and container images.
- sudo privileges β containerlab manages network namespaces and virtual links.
Install steps
containerlab needs a working Docker runtime. Install Docker, enable the service, and add your user to the docker group so you can run labs without root for every command.
# Install Docker (convenience script)
curl -fsSL https://get.docker.com | sh
# Run docker without sudo, then re-login
sudo usermod -aG docker $USER
# Verify the daemon is up
sudo systemctl enable --now docker
docker run --rm hello-worldThe official installer detects your distro and drops the clab/containerlab binary into your PATH. Pin a version in CI for reproducible labs.
# Latest release
bash -c "$(curl -sL https://get.containerlab.dev)"
# Pin a specific version (reproducible CI)
bash -c "$(curl -sL https://get.containerlab.dev)" -- -v 0.59.0
# Confirm the install
containerlab versionNokia SR Linux is publicly available, so it's the quickest way to a first lab. Other NOSes (Arista cEOS, Cisco) need images you import yourself.
# Pull the free SR Linux image
docker pull ghcr.io/nokia/srlinux:latest
# List local images containerlab can use
docker images | grep -E "srlinux|ceos|frr"First lab verification
Save the two-node srl02.clab.yml topology above, then deploy it and watch the node table appear.
containerlab deploy -t srl02.clab.ymlinspect lists each node with status 'running' and a management IP. docker ps should show two clab-srl02 containers.
containerlab inspect -t srl02.clab.yml
docker ps --filter "name=clab-srl02"SSH into srl1, configure the back-to-back link, then ping srl2 to prove the virtual wire works.
ssh admin@clab-srl02-srl1 # password: NokiaSrl1!
# In the SR Linux CLI, verify interfaces are up
show interface ethernet-1/1When you're done, destroy removes the containers and links so nothing lingers on the host.
containerlab destroy -t srl02.clab.yml --cleanupComplete first lab β copy, apply, destroy
Everything you need for a working two-node lab in one place: a full topology YAML with management addressing, the exact commands to apply it, and the commands to tear it down.
1 β Sample topology YAML
# first-lab.clab.yml
# A complete, self-contained two-node lab.
# srl1 <--- ethernet-1/1 ---> srl2 (back-to-back link)
name: first-lab
topology:
nodes:
srl1:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux:latest
mgmt-ipv4: 172.20.20.11
srl2:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux:latest
mgmt-ipv4: 172.20.20.12
links:
- endpoints: ["srl1:e1-1", "srl2:e1-1"]
mgmt:
network: clab-first-lab
ipv4-subnet: 172.20.20.0/242 β Apply (deploy) the lab
# 1. Save the YAML above as first-lab.clab.yml in an empty directory
mkdir -p ~/labs/first-lab && cd ~/labs/first-lab
# (paste the topology into first-lab.clab.yml)
# 2. Deploy (apply) the lab β pulls images, creates nodes + links
sudo containerlab deploy -t first-lab.clab.yml
# 3. Confirm both nodes are running with their mgmt IPs
sudo containerlab inspect -t first-lab.clab.yml
# 4. Connect to a node and check the back-to-back interface
ssh admin@172.20.20.11 # password: NokiaSrl1!
# inside SR Linux:
show interface ethernet-1/13 β Topology diagram
Two SR Linux nodes on a shared management network, joined by a single back-to-back link.
clab-first-lab (mgmt 172.20.20.0/24)
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββββββββββββ βββββββββββββββββ β
β β srl1 β e1-1 β srl2 β β
β β nokia_srlinux ββββββββββ€ nokia_srlinux β β
β β 172.20.20.11 β link β 172.20.20.12 β β
β βββββββββββββββββ βββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββ4 β Expected device status
After deploy, containerlab inspect should show both nodes running with their management IPs.
+---+----------------------+--------------+-----------------------+---------------+---------+----------------+
| # | Name | Container ID | Image | Kind | State | IPv4 Address |
+---+----------------------+--------------+-----------------------+---------------+---------+----------------+
| 1 | clab-first-lab-srl1 | a1b2c3d4e5f6 | ghcr.io/nokia/srlinux | nokia_srlinux | running | 172.20.20.11/24|
| 2 | clab-first-lab-srl2 | f6e5d4c3b2a1 | ghcr.io/nokia/srlinux | nokia_srlinux | running | 172.20.20.12/24|
+---+----------------------+--------------+-----------------------+---------------+---------+----------------+
# Both nodes must show State = running with a /24 mgmt address.5 β Destroy the lab
# Tear the lab down (remove containers + virtual links)
sudo containerlab destroy -t first-lab.clab.yml
# Also delete the generated clab-first-lab/ directory (clean slate for CI)
sudo containerlab destroy -t first-lab.clab.yml --cleanupInteractive runner β click to apply, inspect & destroy
A simulated containerlab session. Click a command to stream realistic output and watch the node status update live. No real containers are created β it's a safe way to see the lifecycle.
Troubleshooting β common first-lab issues
When a first lab misbehaves, work top to bottom: read the logs, find the matching symptom, apply the fix.
Likely cause: No internet access, wrong image ref, or not logged in to the registry.
Logs to check
# Watch the deploy with debug logging
sudo containerlab deploy -t first-lab.clab.yml --debug
# Try the pull manually to see the real error
docker pull ghcr.io/nokia/srlinux:latestFix: Confirm outbound HTTPS to ghcr.io, fix the image: field, then redeploy with --reconfigure.
Likely cause: The container crash-looped on boot (often low memory or a bad startup config).
Logs to check
# Inspect status and the node's own logs
sudo containerlab inspect -t first-lab.clab.yml
docker logs clab-first-lab-srl1 --tail 50Fix: Free up RAM (SR Linux needs ~1 GB/node), remove a broken startup-config, then redeploy.
Likely cause: Your user is not in the docker group, or the daemon is not running.
Logs to check
systemctl status docker
groups $USER # should list 'docker'Fix: Run: sudo usermod -aG docker $USER, log out/in, and sudo systemctl enable --now docker.
Likely cause: The node is still booting, or you used the wrong management IP/name.
Logs to check
sudo containerlab inspect -t first-lab.clab.yml # copy the exact IPv4
docker ps --filter "name=clab-first-lab"Fix: Wait ~30β60s for the NOS to finish booting, then ssh admin@<mgmt-ip> (password NokiaSrl1!).
Likely cause: A previous lab was not cleaned up and left its docker network behind.
Logs to check
docker network ls | grep clab
sudo containerlab inspect --allFix: Run containerlab destroy --cleanup on the old lab (see cleanup step), then redeploy.
Cleanup & verification β confirm a clean slate
Destroy alone usually removes everything, but always verify: leftover containers or docker networks cause "already exists" errors on your next deploy. Each check below should return empty output.
# 1. Destroy and remove the generated lab directory
sudo containerlab destroy -t first-lab.clab.yml --cleanup
# 2. Confirm NO lab containers remain (expect empty output)
docker ps -a --filter "name=clab-first-lab"
# 3. Confirm the management network is gone (expect empty output)
docker network ls | grep clab-first-lab
# 4. Double-check containerlab itself sees no running labs
sudo containerlab inspect --all
# 5. (Optional) prune dangling resources left by old labs
docker network prune -fFirst-lab variants β tweak nodes & links
Same workflow, different topology. Copy a variant's YAML, then run its exact apply/destroy commands.
Swap the SR Linux nodes for Arista cEOS. The image must be imported locally first (docker import cEOS-lab.tar.xz ceos:4.30). Only the kind/image change β links stay the same.
# ceos-lab.clab.yml
name: ceos-lab
topology:
nodes:
ceos1:
kind: arista_ceos
image: ceos:4.30
ceos2:
kind: arista_ceos
image: ceos:4.30
links:
- endpoints: ["ceos1:eth1", "ceos2:eth1"]sudo containerlab deploy -t ceos-lab.clab.yml
sudo containerlab inspect -t ceos-lab.clab.ymlsudo containerlab destroy -t ceos-lab.clab.yml --cleanupUse the lightweight FRR image and attach a node interface to the host with a 'host' link type β handy for bridging a lab into your machine's networking.
# frr-host.clab.yml
name: frr-host
topology:
nodes:
frr1:
kind: linux
image: frrouting/frr:latest
links:
# link type: connect frr1 eth1 to a host interface
- type: host
endpoint:
node: frr1
interface: eth1
host-interface: clab-frr1-eth1sudo containerlab deploy -t frr-host.clab.yml
sudo containerlab inspect -t frr-host.clab.ymlsudo containerlab destroy -t frr-host.clab.yml --cleanupScale to three SR Linux nodes wired in a line. Add nodes under topology.nodes and one more link entry β apply/destroy commands are identical aside from the file name.
# srl-line.clab.yml
name: srl-line
topology:
nodes:
srl1: { kind: nokia_srlinux, image: ghcr.io/nokia/srlinux:latest }
srl2: { kind: nokia_srlinux, image: ghcr.io/nokia/srlinux:latest }
srl3: { kind: nokia_srlinux, image: ghcr.io/nokia/srlinux:latest }
links:
- endpoints: ["srl1:e1-1", "srl2:e1-1"]
- endpoints: ["srl2:e1-2", "srl3:e1-1"]sudo containerlab deploy -t srl-line.clab.yml
sudo containerlab inspect -t srl-line.clab.ymlsudo containerlab destroy -t srl-line.clab.yml --cleanupNext steps β expand your topology
- Add a third node and a second link to turn the line into a triangle (redundant paths).
- Configure an IGP (OSPF/IS-IS) between nodes and verify adjacencies with show commands.
- Add a startup-config per node so the lab boots pre-configured every time.
- Introduce a Linux 'client' node on each side to test end-to-end reachability with ping.
- Point Netmiko, Nornir or Ansible at the node mgmt IPs to automate the config.
- Commit your .clab.yml to git and run containerlab deploy/destroy in a CI pipeline.
Setup, key lab examples & run commands
containerlab runs on Linux with Docker. The install script drops the clab binary in your PATH. You also need the container images for the NOSes you plan to lab (Nokia SR Linux is free to pull).
# Docker must be installed and running first
bash -c "$(curl -sL https://get.containerlab.dev)"
# verify
containerlab version # or: clab versionA topology file declares nodes (by kind + image) and the links between them. This two-node Nokia SR Linux lab connects e1-1 on each switch back to back.
name: srl02
topology:
nodes:
srl1:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux
srl2:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux
links:
- endpoints: ["srl1:e1-1", "srl2:e1-1"]Deploy reads the topology, pulls images if needed, creates the containers and wires up the links. The output table lists each node's name, container and management IP.
containerlab deploy -t srl02.clab.yml
# redeploy from scratch (destroy + deploy)
containerlab deploy -t srl02.clab.yml --reconfigureList running labs and node details with inspect, then SSH or open the NOS CLI on any node by its lab-prefixed name.
# list nodes, status and mgmt IPs
containerlab inspect -t srl02.clab.yml
# connect to the SR Linux CLI
ssh admin@clab-srl02-srl1
# or drop into the container shell
docker exec -it clab-srl02-srl1 sr_cliDestroy removes all containers and the virtual links. Add --cleanup to also delete the generated lab directory β handy for CI pipelines that build a fresh topology each run.
containerlab destroy -t srl02.clab.yml
# also remove the clab-srl02/ lab directory
containerlab destroy -t srl02.clab.yml --cleanupcontainerlab pairs perfectly with automation tools β deploy a topology, then point Netmiko, Nornir or Ansible at the nodes to test configs and CI pipelines before touching real gear.