Create several Podman containers by using different options.
Outcomes
You should be able to run containers in Podman by using the podman run command.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start basics-creating
Instructions
Use the registry.ocp4.example.com:8443/ubi8/ubi-minimal:8.5 image to create a new container that prints the Hello Red Hat text.
Use the podman pull command to fetch the image from the registry.
[student@workstation ~]$ podman pull \
registry.ocp4.example.com:8443/ubi8/ubi-minimal:8.5
Trying to pull registry.ocp4.example.com:8443/ubi8/ubi-minimal:8.5...
...output omitted...
Writing manifest to image destination
Storing signatures
a0c247bdbd39ebaf1d6c8a2b42573311b3052ed0d67cc8eb7518b47f5e0eeca6Use the podman images command to verify that the image is available locally.
[student@workstation ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.ocp4.example.com:8443/ubi8/ubi-minimal 8.5 a0c247bdbd39 4 weeks ago 107 MBIn a command line terminal, use podman run to create a new container. Provide an echo command to be executed inside the container.
[student@workstation ~]$ podman run --rm \
registry.ocp4.example.com:8443/ubi8/ubi-minimal:8.5 echo 'Hello Red Hat'
Hello Red HatVerify that the container is not running after the execution finishes.
[student@workstation ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESExplore setting and printing environment variables by using the registry.ocp4.example.com:8443/ubi8/ubi-minimal:8.5 container image.
Use the -e option in the podman run command to set environment variables. Use the printenv command that is packaged in the container image to print the values of the environment variables.
[student@workstation ~]$ podman run --rm -e GREET=Hello -e NAME='Red Hat' \
registry.ocp4.example.com:8443/ubi8/ubi-minimal:8.5 printenv GREET NAME
Hello
Red HatVerify that the container is not running after the execution finishes.
[student@workstation ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESBy using the registry.ocp4.example.com:8443/ubi8/httpd-24 image, run a new container that creates an Apache HTTP server.
Use the podman run command to pull the container image and start the httpd container. Use the -p option in the podman run command to redirect traffic from port 8080 on your machine to port 8080 inside the container.
[student@workstation ~]$ podman run --rm -p 8080:8080 \
registry.ocp4.example.com:8443/ubi8/httpd-24
[Thu Apr 21 12:58:57.048491 2022] [ssl:warn] [pid 1:tid 140257793613248] AH01909: 10.0.2.100:8443:0 server certificate does NOT include an ID which matches the server name
[Thu Apr 21 12:58:57.048899 2022] [:notice] [pid 1:tid 140257793613248] ModSecurity for Apache/2.9.2 (http://www.modsecurity.org/) configured.
...output omitted...
[Thu Apr 21 12:58:57.136272 2022] [mpm_event:notice] [pid 1:tid 140257793613248] AH00489: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k configured -- resuming normal operations
[Thu Apr 21 12:58:57.136332 2022] [core:notice] [pid 1:tid 140257793613248] AH00094: Command line: 'httpd -D FOREGROUND'The container keeps running and the logs are displayed in your terminal.
In a web browser, navigate to http://localhost:8080. Verify that the HTTP server is running at the 8080 port.
Go back to your command-line terminal. Press Ctrl + C to stop the container.
...output omitted...
^C
[Thu Apr 21 13:00:52.516503 2022] [mpm_event:notice] [pid 1:tid 140481583287744] AH00491: caught SIGTERM, shutting downCreate the container again by adding the -d option. The container runs in the background.
[student@workstation ~]$ podman run --rm -d \
-p 8080:8080 registry.ocp4.example.com:8443/ubi8/httpd-24
c1db10ec1ba61afcc7bb482b8d9cd42995473a4f4523ae15f3253e896a45d61aVerify that the container is running in the background.
[student@workstation ~]$ podman ps
c1db10ec1ba6 registry.ocp4.example.com:8443/ubi8/httpd-24:latest /usr/bin/run-http... About a minute ago Up About a minute ago 0.0.0.0:8080->8080/tcp distracted_lumiereUse Podman Desktop to list images and containers.
Open Podman Desktop.
[student@workstation ~]$ podman-desktopIf a telemetry alert displays, then click .
The telemetry dialog might display under Podman Desktop, blocking any interaction with the main window. If you experience this problem, then move the main window to find the telemetry dialog.
This problem is a known bug. For more details, see https://github.com/containers/podman-desktop/issues/664.
Click in the Podman Desktop navigation panel. The list includes the containers that you created in the exercise. Verify that the Apache HTTP container is running.
![]() |
Click .
The list of local images displays the ubi8/ubi-minimal and ubi8/httpd-24 images.
![]() |
Use Podman Desktop to start another Apache HTTP container that maps its port to port 8090 in the workstation.
Click the icon of the ubi8/httpd-24 image to run a new container based on this image.
In the container creation form, enter the following values:
Container name: desktop-test
Local port for 8080/tcp: 8090
Local port for 8443/tcp: Delete the default value and leave blank
![]() |
Click .
You can safely ignore the SELinux security warning that displays at the top of the desktop.
In the containers list, verify that desktop-test is running.
In the desktop-test container, scroll to the right if necessary, click → , and then click in the confirmation dialog box.
![]() |
Verify that the browser can access the HTTP server at http://localhost:8090.
Return to Podman Desktop.
In the desktop-test container, click the icon to delete the container, and then close Podman Desktop.