srl-labs / containerlab

container-based networking labs
https://containerlab.dev
BSD 3-Clause "New" or "Revised" License
1.53k stars 263 forks source link

Clarification on loading local docker images #488

Closed cdot65 closed 3 years ago

cdot65 commented 3 years ago

Hello, I am just looking for a better understanding on how the lab instantiation process works.

I have loaded an image of cRPD by downloading the tar and performing a docker load -i crpd.tgz, and the image shows accordingly with docker images, yet when I try to launch my images with containerlab, it appears to try to pull the image from a remote repository rather than look for the image locally.

`--> docker images
REPOSITORY   TAG         IMAGE ID       CREATED      SIZE
crpd         20.2R1.10   f9b634369718   9 days ago   374MB
crpd         latest      f9b634369718   9 days ago   374MB
`--> sudo containerlab deploy -t crpd.clab.yml
INFO[0000] Parsing & checking topology file: crpd.clab.yml
INFO[0000] Pulling docker.io/library/crpd:20.2R1.10 Docker image
Error: Error response from daemon: pull access denied for crpd, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
`--> cat crpd.clab.yml
# topology documentation: http://containerlab.srlinux.dev/lab-examples/srl-crpd/
name: crpd
topology:
  nodes:
    crpd1:
      kind: crpd
      image: crpd:20.2R1.10
    crpd2:
      kind: crpd
      image: crpd:20.2R1.10
  links:
    - endpoints: ["crpd1:eth1", "crpd2:eth1"]

Is there a mechanism to have the containerlab software look for the image locally before trying to pull? I would like to avoid having to log into Juniper's container repository

steiler commented 3 years ago

This is supposed to work as you described. Will take a look.

hellt commented 3 years ago

@cremsburg as @steiler says, containerlab uses the local images if they are available, and pulls only if needed Which version are you running?

containerlab version will show it

hellt commented 3 years ago

@cremsburg it works here

❯ docker images | grep crpd
crpd                                20.2R1.10       41d6ae0a8fcb   12 months ago   234MB
❯ bat crpd.yml 
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: crpd.yml
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ name: crpd
   2   │ topology:
   3   │   nodes:
   4   │     crpd1:
   5   │       kind: crpd
   6   │       # image: registry.srlinux.dev/pub/crpd:20.2R1.10
   7   │       image: crpd:20.2R1.10
   8   │     crpd2:
   9   │       kind: crpd
  10   │       # image: registry.srlinux.dev/pub/crpd:20.2R1.10
  11   │       image: crpd:20.2R1.10
  12   │ 
  13   │   links:
  14   │     - endpoints: ["crpd1:eth1", "crpd2:eth1"]
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ ./clab.sh dep -t crpd.yml --reconfigure
INFO[0000] Parsing & checking topology file: crpd.yml   
INFO[0000] Removing /root/testclab/clab-crpd directory... 
INFO[0000] Creating lab directory: /root/testclab/clab-crpd 
INFO[0000] Creating docker network: Name='clab', IPv4Subnet='172.20.20.0/24', IPv6Subnet='2001:172:20:20::/64', MTU='1450' 
INFO[0000] Creating container: crpd1                    
INFO[0000] Creating container: crpd2                    
INFO[0001] Creating virtual wire: crpd1:eth1 <--> crpd2:eth1 
INFO[0001] Writing /etc/hosts file                      
INFO[0001] 🎉 New containerlab version 0.14.4 is available! Release notes: https://containerlab.srlinux.dev/rn/0.14.4
Run 'containerlab version upgrade' to upgrade or go check other installation options at https://containerlab.srlinux.dev/install/ 
+---+-----------------+--------------+----------------+------+-------+---------+----------------+----------------------+
| # |      Name       | Container ID |     Image      | Kind | Group |  State  |  IPv4 Address  |     IPv6 Address     |
+---+-----------------+--------------+----------------+------+-------+---------+----------------+----------------------+
| 1 | clab-crpd-crpd1 | f65ef18ffd15 | crpd:20.2R1.10 | crpd |       | running | 172.20.20.2/24 | 2001:172:20:20::2/64 |
| 2 | clab-crpd-crpd2 | 69fed90b2216 | crpd:20.2R1.10 | crpd |       | running | 172.20.20.3/24 | 2001:172:20:20::3/64 |
+---+-----------------+--------------+----------------+------+-------+---------+----------------+----------------------+

so it is weird, why you don't see the same

cdot65 commented 3 years ago

Here is some information regarding my setup, I believe the problem may be on my side as I took a different approach to installing docker this time around. Instead of doing a standard Docker install, I cloned a rancher node that had it installed through their bash script.

OS: Ubuntu 20.04 LTS Containerlab: latest, installed via bash -c "$(curl -sL https://get-clab.srlinux.dev)" Docker: 20.10.7, build f0df350; installed via Rancher script curl https://releases.rancher.com/install-docker/20.10.sh | sh

I will rebuild my environment to validate

cdot65 commented 3 years ago

2021-07-01_09-52-23

Confirmed, issue was with my Docker install.

This may have been due to the Rancher Docker install script, or it may be due tot he fact that I used the 20.10 script on a 20.04 install of Ubuntu.

Would be great to know more about the problem, but I doubt many others will use my install method. Feel free to close this issue, and thanks for chiming in :D

hellt commented 3 years ago

thanks for confirming!