Red Hat System Administration II
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
Log in to the
serveramachine as thestudentuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$Install the
container-toolsmetapackage. Usestudentas 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!Configure the
registry.lab.example.comclassroom registry in your home directory. Log in to the container registry withadminas the user andredhat321as the password.Create the
/home/student/.config/containersdirectory.[student@servera ~]$
mkdir -p /home/student/.config/containersCreate the
/home/student/.config/containers/registries.conffile with the following contents:unqualified-search-registries = ['registry.lab.example.com'] [[registry]] location = "registry.lab.example.com" insecure = true blocked = false
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...Log in to the classroom registry.
[student@servera ~]$
podman login registry.lab.example.comUsername:adminPassword:redhat321Login Succeeded!
Run the
python312container in detached mode from an image with thepython 3.12package and based on theubi9image. The image is hosted on a remote registry.Search for a
python-312container in theregistry.lab.example.comregistry.[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-24registry.lab.example.com/ubi9/python-312...output omitted...Use the
skopeocommand 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...Pull the
python-312container image.[student@servera ~]$
podman pull registry.lab.example.com/ubi9/python-312Trying to pull registry.lab.example.com/ubi9/python-312:latest... ...output omitted... 7d85f178ae10929ae2fbe742a70d91b8ef432dbe84ff55d0af9f05d9506e9890Verify that the container is downloaded to the local image repository.
[student@servera ~]$
podman imagesREPOSITORY TAG IMAGE ID CREATED SIZE registry.lab.example.com/ubi9/python-312 latest 7d85f178ae10 2 weeks ago 1.08 GBStart the
python312container.[student@servera ~]$
podman run -d --name python312 \registry.lab.example.com/ubi9/python-312 sleep infinityafccc88bd61321b7d7466d71fd692b7bafb63c3e160435fd266e1d50d6263989Verify that the container was created.
[student@servera ~]$
podman psCONTAINER 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
Delete the container and image. Return to
workstation.Stop the container.
[student@servera ~]$
podman stop python312...output omitted... python312Remove the container.
[student@servera ~]$
podman rm python312python312Remove the container image.
[student@servera ~]$
podman rmi \registry.lab.example.com/ubi9/python-312:latestUntagged: registry.lab.example.com/ubi9/python-312:latest Deleted: 7d85...9890Return to
workstation.[student@servera ~]$
exitlogout Connection to servera closed.