Bookmark this page

Guided Exercise: Container Image Registries

Use Podman to pull container images from a registry, and use the images to run containers.

Outcomes

  • Configure a container image registry and create a container from an existing image.

  • Delete containers and images.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

[student@workstation ~]$ lab start containers-basics

Instructions

  1. Log in to the servera machine as the student user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$
  2. Install the container-tools metapackage. Use student as the password.

    [student@servera ~]$ sudo dnf install container-tools
    [sudo] password for student: student
    ...output omitted...
    Is this ok [y/N]: y
    ...output omitted...
    Complete!
  3. Configure the registry.lab.example.com classroom registry in your home directory. Log in to the container registry with admin as the user and redhat321 as the password.

    1. Create the /home/student/.config/containers directory.

      [student@servera ~]$ mkdir -p /home/student/.config/containers
    2. Create the /home/student/.config/containers/registries.conf file with the following contents:

      unqualified-search-registries = ['registry.lab.example.com']
      
      [[registry]]
      location = "registry.lab.example.com"
      insecure = true
      blocked = false
    3. Verify that the classroom registry is added.

      [student@servera ~]$ podman info
      ...output omitted...
      registries:
        registry.lab.example.com:
          Blocked: false
          Insecure: true
          Location: registry.lab.example.com
          MirrorByDigestOnly: false
          Mirrors: null
          Prefix: registry.lab.example.com
        search:
        - registry.lab.example.com
      ...output omitted...
    4. Log in to the classroom registry.

      [student@servera ~]$ podman login registry.lab.example.com
      Username: admin
      Password: redhat321
      Login Succeeded!
  4. Run the python312 container in detached mode from an image with the python 3.12 package and based on the ubi9 image. The image is hosted on a remote registry.

    1. Search for a python-312 container in the registry.lab.example.com registry.

      [student@servera ~]$ podman search registry.lab.example.com/
      NAME                                        DESCRIPTION
      ...output omitted...
      registry.lab.example.com/rhel9/mariadb-105
      registry.lab.example.com/rhel9/httpd-24
      registry.lab.example.com/ubi9/python-312
      ...output omitted...
    2. Use the skopeo command to inspect the image.

      [student@servera ~]$ skopeo inspect \
      docker://registry.lab.example.com/ubi9/python-312
      ...output omitted...
              "description": "Python 3.12 available as container is a base platform for building and running various Python 3.12 applications and frameworks.
      ...output omitted...
    3. Pull the python-312 container image.

      [student@servera ~]$ podman pull registry.lab.example.com/ubi9/python-312
      Trying to pull registry.lab.example.com/ubi9/python-312:latest...
      ...output omitted...
      7d85f178ae10929ae2fbe742a70d91b8ef432dbe84ff55d0af9f05d9506e9890
    4. Verify that the container is downloaded to the local image repository.

      [student@servera ~]$ podman images
      REPOSITORY                                TAG     IMAGE ID      CREATED      SIZE
      registry.lab.example.com/ubi9/python-312  latest  7d85f178ae10  2 weeks ago  1.08 GB
    5. Start the python312 container.

      [student@servera ~]$ podman run -d --name python312 \
      registry.lab.example.com/ubi9/python-312 sleep infinity
      afccc88bd61321b7d7466d71fd692b7bafb63c3e160435fd266e1d50d6263989
    6. Verify that the container was created.

      [student@servera ~]$ podman ps
      CONTAINER ID  IMAGE                                            COMMAND         CREATED         STATUS        PORTS       NAMES
      afccc88bd613  registry.lab.example.com/ubi9/python-312:latest  sleep infinity  21 seconds ago  Up 21 seconds             python312
  5. Delete the container and image. Return to workstation.

    1. Stop the container.

      [student@servera ~]$ podman stop python312
      ...output omitted...
      python312
    2. Remove the container.

      [student@servera ~]$ podman rm python312
      python312
    3. Remove the container image.

      [student@servera ~]$ podman rmi \
      registry.lab.example.com/ubi9/python-312:latest
      Untagged: registry.lab.example.com/ubi9/python-312:latest
      Deleted: 7d85...9890
    4. Return to workstation.

      [student@servera ~]$ exit
      logout
      Connection to servera closed.

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish containers-basics

Revision: rh199-9.3-8dd73db