A network lab used to be a rack, a week of cabling and a licence. With containerlab it is a YAML file and one command: the nodes are containers running a real network OS, the links are virtual wires between them. This page installs the tooling on one Linux machine, brings up a spine and two leaves, configures the first links, and puts the whole thing in git so the next pages can build on it.
Before you start
$sudo apt update && sudo apt install -y curl git$mkdir -p $lsb_release -is && docker --version >/dev/null 2>&1 || echo no-docker-yetUbuntu no-docker-yet
Install Docker and containerlab
$curl -fsSL https://get.docker.com | sudo sh$sudo usermod -aG docker $USER$newgrp docker$docker run --rm hello-world | head -2Then containerlab, pinned to :
$sudo bash -c "$(curl -sL https://get.containerlab.dev)" -- -v $containerlab version$containerlab version | grep -o 'version: 'version:
Get the image
$docker pull $docker image ls -q | wc -l1
Write the topology
name: mgmt: network: -mgmt ipv4-subnet: topology: kinds: nokia_srlinux: image: nodes: spine1: { kind: nokia_srlinux, mgmt-ipv4: } leaf1: { kind: nokia_srlinux, mgmt-ipv4: } leaf2: { kind: nokia_srlinux, mgmt-ipv4: } links: - endpoints: ["spine1:e1-1", "leaf1:e1-1"] - endpoints: ["spine1:e1-2", "leaf2:e1-1"]$cd && python3 -c 'import yaml; t = yaml.safe_load(open("topology.clab.yml")); print(len(t["topology"]["nodes"]), len(t["topology"]["links"]))'3 2
Deploy and look around
$cd $sudo containerlab deploy -t topology.clab.yml$sudo containerlab inspect -t topology.clab.ymlLog in to a node. containerlab created /etc/hosts entries, and the default credentials are admin / NokiaSrl1!:
$ssh admin@A:spine1# show versionA:spine1# show interface brief$docker ps --filter name=clab-- -q | wc -l3
$sudo containerlab inspect -t /topology.clab.yml | grep -c running3
If a node stays in 'created' or restarts
docker logs clab-<V name="LAB_NAME" />-spine1 tells. The usual causes: not enough RAM (the kernel kills the biggest process, dmesg | grep -i kill), or a management subnet that overlaps a network the host already has (ip route; pick another ). Destroy, fix, redeploy.
A first configuration
enter candidateset / interface ethernet-1/1 admin-state enableset / interface ethernet-1/1 subinterface 0 admin-state enableset / interface ethernet-1/1 subinterface 0 ipv4 admin-state enableset / interface ethernet-1/1 subinterface 0 ipv4 address 10.1.0.0/31set / interface ethernet-1/2 admin-state enableset / interface ethernet-1/2 subinterface 0 admin-state enableset / interface ethernet-1/2 subinterface 0 ipv4 admin-state enableset / interface ethernet-1/2 subinterface 0 ipv4 address 10.1.0.2/31set / network-instance default interface ethernet-1/1.0set / network-instance default interface ethernet-1/2.0commit nowFrom spine1, ping leaf1 across the link:
ping -c 3 10.1.0.1 network-instance default$docker exec clab--spine1 sr_cli 'ping -c 3 10.1.0.1 network-instance default' | grep -o '3 received'3 received
Save, destroy, redeploy
$cd $sudo containerlab save -t topology.clab.yml$ls clab-/$sudo containerlab destroy -t topology.clab.yml$sudo containerlab deploy -t topology.clab.yml$sudo containerlab inspect -t /topology.clab.yml | grep -c running3
The lab in git
clab-*/*.tar.xz.venv/$cd $git init$git add topology.clab.yml .gitignore$git commit -m "containerlab topology: spine1, leaf1, leaf2"$git -C status --short | wc -l0
Done
Three SR Linux nodes run on , wired spine-to-leaf, reachable on , and , and the topology is in git. You can destroy and rebuild the whole thing in two commands:
$cd && sudo containerlab destroy -t topology.clab.yml --cleanup && sudo containerlab deploy -t topology.clab.ymlThe addresses you typed by hand in this page are the last ones you will type: the next page models the lab in NetBox, devices, interfaces, cables and IPs, so that configuration can be generated from it.