Stage 2.2 - Docker and ContainerLab

Return to Workshop

Stage 2 Docker and ContainerLab Basics

Estimated time to complete: 15 minutes

Stages

In Stage 2, we will discuss Docker and ContainerLab basics.

We will run through some of the commands and concepts to better understand Docker and ContainerLab.

Utilizing containers to create multiple network devices in minutes.

Allows us to easily deploy and test changes prior to releasing it to production.


Here are the requirements for Stage 2

Requirements

Here is a diagram of Stage 2. This shows all the technology we will be using in Stage 2.

It also defines the use cases we will be working on in Stage 2.

Diagram

Here is a summary of Stage 2

Stage 2 Summary

Let’s fire up some switches on Server 1

We will use ContainerLab to create a 5 node spin leaf Arista environment with three Linux Clients on Server 1

These devices will all be created in Docker

Let’s check out docker from a terminal command prompt

Run the following commands:

Both of these commands perform the same tasks

docker ps
docker container ls

There should be no containers running

cloud_user@ed26757f4b1c:~/network-automation/infra$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
cloud_user@ed26757f4b1c:~/network-automation/infra$

We need to import the Arista switch container image into your docker repository – be patient

Run the following command:

docker import ~/network-automation/infra/cEOS-lab-4.25.10M.tar.tar ceos:4.25.10M

This will take some time. It is pulling down the Arista Lab Container Image into Docker

Run the following command after it completes:

docker image ls
cloud_user@ed26757f4b2c:~/network-automation/infra$ docker import network-automation/infra/cEOS-lab-4.25.10M.tar.tar ceos:4.25.10M
sha256:1d338447c13d9594f6c3c99c13f24be285555595f590b57c44a54b71e2e664a7
cloud_user@ed26757f4b2c:~$ docker image ls
REPOSITORY   TAG        IMAGE ID       CREATED              SIZE
ceos         4.25.10M   1d338447c13d   About a minute ago   1.62GB
cloud_user@ed26757f4b2c:~/network-automation/infra$

Create a 5 node spin leaf Arista environment

We will use ContainerLab to create a 5 node spin leaf Arista environment with three Linux Clients

Run the following command to spin up the network and Linux clients

sudo containerlab deploy -t ~/network-automation/infra/ceos_2spine_3leaf.yaml --reconfigure --max-workers 30
Note: Depending on the Server Specs – Performance may vary. Takes about 5 to 7 minutes for the switches to complete.
cloud_user@ed26757f4b2c:~/network-automation/infra$ sudo containerlab deploy -t ~/network-automation/infra/ceos_2spine_3leaf.yaml --reconfigure --max-workers 30
[sudo] password for cloud_user:
INFO[0000] Containerlab v0.48.6 started
INFO[0000] Parsing & checking topology file: ceos_2spine_3leaf.yaml
INFO[0000] Creating docker network: Name="clab", IPv4Subnet="172.20.20.0/24", IPv6Subnet="2001:172:20:20::/64", MTU='ל'
INFO[0000] Could not read docker config: open /root/.docker/config.json: no such file or directory
INFO[0000] Pulling ghcr.io/hellt/network-multitool:latest Docker image
INFO[0005] Done pulling ghcr.io/hellt/network-multitool:latest
INFO[0006] Creating lab directory: /home/cloud_user/network-automation/infra/clab-Arista-2s-3l
INFO[0006] Creating container: "client3"
INFO[0006] Creating container: "spine2"
INFO[0009] Creating container: "client1"
INFO[0009] Creating container: "client2"
INFO[0010] Creating container: "leaf2"
INFO[0010] Creating container: "leaf1"
INFO[0011] Creating link: leaf2:eth2 <--> spine2:eth2
INFO[0011] Creating link: client2:eth1 <--> leaf2:eth3
INFO[0011] Creating container: "leaf3"
INFO[0011] Creating link: leaf1:eth2 <--> spine2:eth1
INFO[0011] Creating link: client1:eth1 <--> leaf1:eth3
INFO[0012] Creating container: "spine1"
INFO[0012] Creating link: leaf3:eth2 <--> spine2:eth3
INFO[0012] Creating link: client3:eth1 <--> leaf3:eth3
INFO[0012] Creating link: leaf1:eth1 <--> spine1:eth1
INFO[0012] Creating link: leaf2:eth1 <--> spine1:eth2
INFO[0013] Creating link: leaf3:eth1 <--> spine1:eth3
INFO[0013] Running postdeploy actions for Arista cEOS 'leaf1' node
INFO[0013] Running postdeploy actions for Arista cEOS 'spine2' node
INFO[0013] Running postdeploy actions for Arista cEOS 'leaf2' node
INFO[0013] Running postdeploy actions for Arista cEOS 'leaf3' node
INFO[0013] Running postdeploy actions for Arista cEOS 'spine1' node
INFO[0288] Adding containerlab host entries to /etc/hosts file
INFO[0288] Adding ssh config for containerlab nodes
+---+---------------------------+--------------+---------------------------------+-------+---------+-----------------+-----------------------+
| # |           Name            | Container ID |              Image              | Kind  |  State  |  IPv4 Address   |     IPv6 Address      |
+---+---------------------------+--------------+---------------------------------+-------+---------+-----------------+-----------------------+
| 1 | clab-Arista-2s-3l-client1 | bed4b729f4ae | ghcr.io/hellt/network-multitool | linux | running | 172.20.20.31/24 | 2001:172:20:20::31/64 |
| 2 | clab-Arista-2s-3l-client2 | f524c21bf58b | ghcr.io/hellt/network-multitool | linux | running | 172.20.20.32/24 | 2001:172:20:20::32/64 |
| 3 | clab-Arista-2s-3l-client3 | 44ac3410b3b1 | ghcr.io/hellt/network-multitool | linux | running | 172.20.20.33/24 | 2001:172:20:20::33/64 |
| 4 | clab-Arista-2s-3l-leaf1   | 103c3bf271eb | ceos:4.25.10M                   | ceos  | running | 172.20.20.21/24 | 2001:172:20:20::21/64 |
| 5 | clab-Arista-2s-3l-leaf2   | d80dd032c45f | ceos:4.25.10M                   | ceos  | running | 172.20.20.22/24 | 2001:172:20:20::22/64 |
| 6 | clab-Arista-2s-3l-leaf3   | d4b34bf63926 | ceos:4.25.10M                   | ceos  | running | 172.20.20.23/24 | 2001:172:20:20::23/64 |
| 7 | clab-Arista-2s-3l-spine1  | 5784ac1282df | ceos:4.25.10M                   | ceos  | running | 172.20.20.11/24 | 2001:172:20:20::11/64 |
| 8 | clab-Arista-2s-3l-spine2  | 0efa144679ad | ceos:4.25.10M                   | ceos  | running | 172.20.20.12/24 | 2001:172:20:20::12/64 |
+---+---------------------------+--------------+---------------------------------+-------+---------+-----------------+-----------------------+

Login to the Spine switch

All username are admin and passwords are admin. Notice all the configurations are default
ssh admin@clab-Arista-2s-3l-spine1
cloud_user@ed26757f4b2c:~/network-automation/infra$ ssh admin@clab-Arista-2s-3l-spine1
The authenticity of host 'clab-arista-2s-3l-spine1 (2001:172:20:20::2)' can't be established.
ECDSA key fingerprint is SHA256:J9FdkpeHpi5dq94nRSVAOJyvtyCnvhapwmLMjBh7vqU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'clab-arista-2s-3l-spine1,2001:172:20:20::2' (ECDSA) to the list of known hosts.
Password:
spine1>en
spine1#sho run
! Command: show running-config
! device: spine1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 $6$cd2Qg0NlrcsduKJ0$4.dQJtZlHWX3lywq1wbJHzTjuLL0VsH60ehELYN3.VfSkLPnYgRpIehMC29ikbMP0kkT3HCzzCV0UQnRt/tgh/
!
transceiver qsfp default-mode 4x10G
!
service routing protocols model multi-agent
!
hostname spine1
!
spanning-tree mode mstp
!

ContainerLab Commands

sudo containerlab -h
cloud_user@ed26757f4b2c:~/network-automation/infra$ sudo containerlab -h
deploy container based lab environments with a user-defined interconnections

Usage:
  containerlab [command]

Available Commands:
  completion  generate completion script
  config      configure a lab
  deploy      deploy a lab
  destroy     destroy a lab
  exec        execute a command on one or multiple containers
  generate    generate a Clos topology file, based on provided flags
  graph       generate a topology graph
  help        Help about any command
  inspect     inspect lab details
  save        save containers configuration
  tools       various tools your lab might need
  version     show containerlab version or upgrade

Flags:
  -d, --debug count        enable debug mode
  -h, --help               help for containerlab
      --log-level string   logging level; one of [trace, debug, info, warning, error, fatal] (default "info")
      --name string        lab name
  -r, --runtime string     container runtime
      --timeout duration   timeout for external API requests (e.g. container runtimes), e.g: 30s, 1m, 2m30s (default 2m0s)
  -t, --topo string        path to the topology file
      --vars string        path to the topology template variables file

Use "containerlab [command] --help" for more information about a command.
cloud_user@ed26757f4b2c:~$

End Result

At this point, you have deployed 5 Arista switches with 3 Linux clients in containers with default configurations.

Return to Workshop