Skip to content

Instantly share code, notes, and snippets.

@mathershifter
Last active January 15, 2025 19:16
Show Gist options
  • Save mathershifter/15554b668efa3febc356ed8304437e64 to your computer and use it in GitHub Desktop.
Save mathershifter/15554b668efa3febc356ed8304437e64 to your computer and use it in GitHub Desktop.
Docker + WSL2 + Containerlab

Docker + WSL2 + Containerlab

Hyper-V

  • Open a PowerShell prompt as Administrator

  • Enable Hyper-V

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

WSL

  • Open a PowerShell prompt

    PS C:\Users\...> wsl.exe --install --no-distribution
    The requested operation requires elevation.
    
    Deployment Image Servicing and Management tool
    Version: 10.0.19041.3636
    
    Image Version: 10.0.19045.5371
    
    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.
    The requested operation is successful. Changes will not be effective until the system is rebooted.
  • Restart the computer

  • Verify

    PS> wsl --status
    Default Version: 2
  • Install Ubuntu

    PS> wsl --install
    Installing: Ubuntu
    Ubuntu has been installed.
    Launching Ubuntu...
    Installing, this may take a few minutes...
    Please create a default UNIX user account. The username does not need to match your Windows username.
    For more information visit: https://aka.ms/wslusers
  • Add user and set password

    Enter new UNIX username: ...
    New password:
    Retype new password:
    passwd: password updated successfully
    Installation successful!
    
  • Instal will continue...

    ...
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
    
    Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/pro
    
     System information as of Tue Jan 14 16:28:43 PST 2025
    
      System load:  0.39                Processes:             67
      Usage of /:   0.1% of 1006.85GB   Users logged in:       0
      Memory usage: 3%                  IPv4 address for eth0: 172.29.144.11
      Swap usage:   0%
    
    
    This message is shown once a day. To disable it please create the
    /home/.../.hushlogin file.

Install Containerlab + Dependencies

  • Install containerlab

    This will install docker, containerlab, and gh CLI. See: https://containerlab.dev/install

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

cEOS

  • Download cEOS from https://www.arista.com/en/support/software-download

  • The image can be found under EOS / Active Releases / / cEOS-Lab / cEOS-lab-.tar.xz

  • Load the cEOS image, for example:

    docker import Downloads/cEOS-lab-4.33.1.1F.tar.xz ceos:<version>
    sha256:72f77d8056c31901f2f27dea15638475c51b823df58e8d777bb5b6756592b2d6
    

Create a simple lab

  • Initialize the lab directory and config file
mkdir -p labs/simple
cd labs/simple
touch simple.clab.yml
  • Edit the lab config
name: simple
topology:
  nodes:
    ceos1:
      kind: ceos
      image: ceos:4.33.1.1F
    ceos2:
      kind: ceos
      image: ceos:4.33.1.1F

  links:
    - endpoints: ["ceos1:eth1", "ceos2:eth1"]
  • Deploy

    $ sudo containerlab deploy
    INFO[0000] Containerlab v0.61.0 started
    INFO[0000] Parsing & checking topology file: simple.clab.yml
    INFO[0000] Creating lab directory: /mnt/c/Users/jrmat/containerlab/simple/clab-simple
    INFO[0000] Creating container: "ceos2"
    INFO[0000] Creating container: "ceos1"
    INFO[0002] Running postdeploy actions for Arista cEOS 'ceos2' node
    INFO[0002] Created link: ceos1:eth1 <--> ceos2:eth1
    INFO[0002] Running postdeploy actions for Arista cEOS 'ceos1' node
    INFO[0030] Adding containerlab host entries to /etc/hosts file
    INFO[0030] Adding ssh config for containerlab nodes
    ╭───────────────────┬────────────────┬─────────┬─────────────────────╮
    │        Name       │   Kind/Image   │  State  │    IPv4/6 Address   │
    ├───────────────────┼────────────────┼─────────┼─────────────────────┤
    │ clab-simple-ceos1 │ arista_ceos    │ running │ 172.100.100.3       │
    │                   │ ceos:4.33.1.1F │         │ 3fff:172:100:100::3 │
    ├───────────────────┼────────────────┼─────────┼─────────────────────┤
    │ clab-simple-ceos2 │ arista_ceos    │ running │ 172.100.100.2       │
    │                   │ ceos:4.33.1.1F │         │ 3fff:172:100:100::2 │
    ╰───────────────────┴────────────────┴─────────┴─────────────────────╯
    
  • Connect to a cEOS container

$ docker exec -it clab-simple-ceos1 Cli -p15
ceos1#show version
Arista cEOSLab
Hardware version:
Serial number: 3C04329CD6D07A915DCFCC54C27F3D0A
Hardware MAC address: 001c.7321.42d9
System MAC address: 001c.7321.42d9

Software image version: 4.33.1.1F-40155285.43311F (engineering build)
Architecture: x86_64
Internal build version: 4.33.1.1F-40155285.43311F
Internal build ID: c27a616c-c821-4fa3-8f7a-4121fc867b45
Image format version: 1.0
Image optimization: None

Kernel version: 5.15.167.4-microsoft-standard-WSL2

Uptime: 12 minutes
Total memory: 16342192 kB
Free memory: 12142100 kB
  • Verify connectivity
ceos1#show lldp neighbors Ethernet 1 detail
Interface Ethernet1 detected 1 LLDP neighbors:

  Neighbor 001c.735b.d3e3/"Ethernet1", age 14 seconds
  Discovered 0:13:46 ago; Last changed 0:13:46 ago
  - Chassis ID type: MAC address (4)
    Chassis ID     : 001c.735b.d3e3
  - Port ID type: Interface name(5)
    Port ID     : "Ethernet1"
  - Time To Live: 120 seconds
  - System Name: "ceos2"
  - System Description: "Arista Networks EOS version 4.33.1.1F-40155285.43311F (engineering build) running on an Arista cEOSLab"
  - System Capabilities : Bridge, Router
    Enabled Capabilities: Bridge
  - Management Address Subtype: IPv4
    Management Address        : 172.100.100.2
    Interface Number Subtype  : ifIndex (2)
    Interface Number          : 999000
    OID String                :
  - IEEE802.1 Port VLAN ID: 1
  - IEEE802.3 Link Aggregation
    Link Aggregation Status: Capable, Disabled (0x01)
    Port ID                : 0
  - IEEE802.3 Maximum Frame Size: 9236 bytes
  - LLDP-MED Inventory Serial Number TLV: "7EE7697A92C6167E84587CF7434C3731"

---- WARNING DOCKER DESKTOP + WSL2 METHOD IS NOT WORKING ----

Install Docker Desktop

  • Follow the instructions to install Docker desktop here.
  • Ensure "Use WSL 2 instead of Hyper-V (recommended)" is checked
  • Restart the computer

Verify docker

  • Enter WSL2

    PS > wsl
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
  • Run hello-world

    $ docker run --rm hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    c1ec31eb5944: Download complete
    Digest: sha256:5b3cc85e16e3058003c13b7821318369dad01dac3dbb877aac3c28182255c724
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/

Manually create an cEOS container

  • First import a cEOS image

  • Create cEOS container

    $ docker create --name=ceos --privileged \
      -e CEOS=1 \
      -e container=docker \
      -e EOS_PLATFORM=ceoslab \
      -e SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
      -e ETBA=1 -e INTFTYPE=eth \
      -it ceos:<version> /sbin/init
    
  • Start the container

    docker start ceos
    

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment