Containerlab is a CLI tool for building and managing labs with containerized network devices. It provides a simple and efficient way to create both small and large network topologies using Docker containers.
The repository is organized as follows:
.github/workflows: Contains GitHub Actions workflows for CI/CD.bin: Directory where the built containerlab binary is placed.cmd: Contains the main command-line interface code for containerlab written with Cobra framework.core: Contains the core logic of containerlab, including lab management, topology parsing, and other functionalities.docs: Contains the documentation for containerlab, built with the Zensical static site generator.nodes: Contains the definitions and implementations of different types of network nodes that can be used in labs.links: Contains the logic for managing links between nodes in the lab.tests: Contains unit and integration tests for containerlab.runtime: Contains the runtime (docker and podman) logic for managing the lifecycle of labs and nodes.
Documentation is built with the Zensical static site generator (the successor to mkdocs-material, by the same team) and is present in the docs directory. Zensical is installed via the docs uv dependency group and still reads the existing mkdocs.yml configuration. To serve the documentation locally, use:
make serve-docsTo cleanup all started labs, use:
clab des -a -c -yTo format the code, use:
make formatThe build and test automation is done in Makefile.
To build the clab binary, use:
make buildWhen building, the containerlab binary (alias clab) is placed in the bin directory.
The unit tests are implemented with Go's built-in testing framework. To run the tests, use the following command:
make testThe integration tests are implemented with Robot Framework. To run the tests, use the following command:
CLAB_BIN=$(pwd)/bin/containerlab ./tests/rf-run.sh docker tests/<path to robot file>When integration tests are run, the lab is destroyed automatically after the test ends.
To run lab deployment with debug logs, use -d flag.