Here are the steps to get Jenkins up and running using Docker and Containerlab.

  • Open up your Kali or Linux distro
  • Create a containerlab file
touch cicd.clab.yml
  • Open the .yml file and add the following code
    • vim cicd.clab.yml
name: cicd_topo
 
topology:
  nodes:
    jenkins:
      kind: linux
      image: jenkins/jenkins
      ports:
        - 8080:8080

For some reason I had to restart the Docker service.

└─$ sudo service docker start
Starting Docker: docker.
  • Start containerlab using the yml file we just created
└─$ sudo containerlab deploy --topo cicd.clab.yml
INFO[0000] Containerlab v0.51.1 started
INFO[0000] Parsing & checking topology file: cicd.clab.yml
INFO[0000] Creating docker network: Name="clab", IPv4Subnet="172.20.20.0/24", IPv6Subnet="2001:172:20:20::/64", MTU='ל'
WARN[0000] errors during iptables rules install: not available
INFO[0000] Could not read docker config: open /root/.docker/config.json: no such file or directory
INFO[0000] Pulling docker.io/jenkins/jenkins:latest Docker image
INFO[0014] Done pulling docker.io/jenkins/jenkins:latest
WARN[0014] Unable to init module loader: stat /lib/modules/5.15.133.1-microsoft-standard-WSL2/modules.dep: no such file or directory. Skipping...
INFO[0014] Creating lab directory: /home/kali/clab/clab-cicd_topo
INFO[0015] Creating container: "jenkins"
INFO[0015] Adding containerlab host entries to /etc/hosts file
INFO[0015] Adding ssh config for containerlab nodes
#NameContainer IDImageIPv4 Address
1clab-cicd_topo-jenkins977474949fd1jenkins/jenkins172.20.20.2/24

When I navigate to http://localhost:8080/ I get the following message.

  • Let’s shell into the docker image and get that password.
┌──(kali㉿LAPTOP-AF9MIU0S)-[~/clab]
└─$ sudo docker exec -it clab-cicd_topo-jenkins sh
$ cat /var/jenkins_home/secrets/initialAdminPassword
24667f370db24643bc5143969782497a

I then clicked the Start using Jenkins button as shown above and we are in!