Pulling an Image

Scenario

To use an image stored in a repository, you need to pull it from the repository first. Then, you can use this image to deploy containerized applications in CCE or CCI. Pulling an image is actually downloading an image.

You can use Docker or containerd to pull images from SWR.

Docker

  1. Log in to the VM running Docker as the root user.

  2. Obtain a login command by referring to 1 and access SWR.

  3. Log in to the SWR console.

  4. In the navigation pane, choose My Images. Then click the name of the target image.

  5. On the image details page, click image1 next to the docker pull command on the Pull/Push tab.

  6. Replace {Tag} in the image download command copied in 5 with the tag of the image to be downloaded and run the command on the VM.

    Run the docker images command to check whether the images are successfully pulled.

    # docker images
    REPOSITORY                                  TAG       IMAGE ID       CREATED         SIZE
    xxx/group/nginx                             v2.0.0    22f2bf2e2b4f   5 hours ago     22.8MB
    
  7. (Optional) Run the following command to save the image as an archive file:

    docker save [Image name:tag name] > [Archive file name]

containerd

  1. Log in to the SWR console.

  2. In the navigation pane, choose My Images. Then click the name of the target image.

  3. On the Tags tab, click containerd command in the Operation column to copy the image pull command. Alternatively, go to the Pull/Push tab to copy the image pull command.

    Note

    The command is only valid for six hours after it is generated. To obtain a long-term valid command, see Obtaining a Long-Term Valid containerd Pull/Push Command.

  4. Log in to the VM running containerd as the root user.

  5. Run the command copied in 3.

    • If the command was copied from the Operation column, run it as follows.

      image2

    • If the command was copied from the Pull/Push tab, run it as follows (replace {Tag} with the new image tag).

      image3

  6. Check whether the image is pulled successfully.

    • If the command was copied from the Operation column, run crictl images to check whether the pull is successful.

      image4

    • If the command was copied from the Pull/Push tab, run ctr images list to check whether the pull is successful.

      image5