Run Containers with Podman on Oracle Linux
Introduction
Podman provides a lightweight utility to run and manage Open Container Initiative (OCI) compatible containers. It can use existing container images that are designed for Oracle Container Runtime for Docker, Oracle Cloud Native Environment and Kubernetes.
Podman integrates with Oracle Container Registry and Docker Hub to share applications in a software-as-a-service (SaaS) cloud.
Objectives
In this lab, you'll learn how to:
- Install Podman
- Search container registries for images
- Pull down images to local storage
- Examine container information
- Create and run containers
- Start, stop, and attach to containers
- Execute commands in running containers
- View container log files
- Remove containers
- Remove images from local storage
Prerequisites
- A running Oracle Linux 9 instance
Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.
Install Podman
Open a terminal and connect via ssh to the ol-node01 instance IP address.
ssh oracle@<ip_address_of_ol_node01>
Install the
container-tools
package.sudo dnf install -y container-tools
This command will install the container-tools package which contains podman (if not already installed) and other tools, including skopeo and buildah. One essential tool is container-selinux which allows running podman as a non-root user on a SELinux enabled system.
Check Podman is installed, and its version.
podman version
Example Output:
Client: Podman Engine Version: 4.4.1 API Version: 4.4.1 Go Version: go1.19.10 Built: Wed Aug 9 19:48:36 2023 OS/Arch: linux/amd64
Podman pulls down images and uses them to create containers.
Run a simple test to show Podman is working and can access image registries.
podman run quay.io/podman/hello
Example Output:
[oracle@ol-node-01 ~]$ podman run quay.io/podman/hello Trying to pull quay.io/podman/hello:latest... Getting image source signatures Copying blob d08b40be6878 done Copying config e2b3db5d4f done Writing manifest to image destination Storing signatures !... Hello Podman World ...! .--"--. / - - \ / (O) (O) \ ~~~| -=(,Y,)=- | .---. /` \ |~~ ~/ o o \~~~~.----. ~~ | =(X)= |~ / (O (O) \ ~~~~~~~ ~| =(Y_)=- | ~~~~ ~~~| U |~~ Project: https://github.com/containers/podman Website: https://podman.io Documents: https://docs.podman.io Twitter: @Podman_io [oracle@ol-node-01 ~]$
List any downloaded images.
podman images
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/podman/hello latest e2b3db5d4fdf 2 weeks ago 82.3 kB [oracle@ol-node-01 ~]$
There is often more than one command to get the same result. Use the command for managing images to show the same image list.
podman image list
Note: You can also use the variation
podman image ls
.Example Output:
[oracle@ol-node-01 ~]$ podman image list REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/podman/hello latest e2b3db5d4fdf 2 weeks ago 82.3 kB [oracle@ol-node-01 ~]$
View documentation pages and command help.
man podman
podman help
Search for images to use in containers
View the default container registries configured during installation of the container-tools package.
Look for the section
unqualified-search-registries
, which identifies the default registries that will be used.cat /etc/containers/registries.conf
Example Output:
[oracle@ol-node-01 ~]$ cat /etc/containers/registries.conf . . unqualified-search-registries = ["container-registry.oracle.com", "docker.io"] . .
Note: These are the registries that will be checked when searching for images or pulling images to be used to create containers.
Search for any images matching
oracle
in all configured registries.podman search oracle
Note: The results displayed are limited to the top 25 entries for each container registry searched. The results can be affected by how the different registries are implemented.
Example Output:
[oracle@ol-node-01 ~]$ podman search oracle NAME DESCRIPTION container-registry.oracle.com/verrazzano/keycloak-oracle-theme This image is part of, and for use with, the... container-registry.oracle.com/os/oraclelinux Oracle Linux container-registry.oracle.com/oracle_linux_automation_manager/olam-ee This image is part of and for use with the O... container-registry.oracle.com/oracle_linux_automation_manager/olam-builder This image supports Builder Utility and for... container-registry.oracle.com/middleware/oracle/shared/idmcache Oracle Advanced Authentication - Cache container-registry.oracle.com/middleware/oracle/shared/oaa-mgmt Oracle Advanced Authentication - Install and... docker.io/library/oraclelinux Official Docker builds of Oracle Linux. docker.io/kasmweb/oracle-8-desktop Oracle Linux 8 desktop for Kasm Workspaces docker.io/kasmweb/oracle-7-desktop Oracle Linux 7 desktop for Kasm Workspaces docker.io/kasmweb/oracle-9-desktop Oracle 9 desktop for Kasm Workspaces docker.io/dokken/oraclelinux-7 Oracle Linux 7 image for kitchen-dokken docker.io/dokken/oraclelinux-6 Oracle Linux 6 image for kitchen-dokken docker.io/dokken/oraclelinux-9 Oracle Linux 9 image for use with Test Kitch... docker.io/paketobuildpacks/oracle docker.io/dokken/oraclelinux-8 docker.io/vulhub/oracle docker.io/kasmweb/core-oracle-8 Oracle Linux 8 base image for Kasm Workspace... docker.io/abesesr/oracle-db-backup Scripts used to periodically backup an oracl... docker.io/kasmweb/core-oracle-7 Oracle Linux 7 base image for Kasm Workspace... docker.io/kasmweb/core-oracle-9 Oracle Linux 9 base image for Kasm Workspace... docker.io/dockette/adminer My most tiniest (10mb) Adminer image with su... docker.io/dockette/mvn My MVN 3 based on Oracle Java Dockerfile docker.io/redislabs/redis-connect-oracle Redis Connect Oracle Connector for Continuou... docker.io/dockette/jdk8 My Oracle Java 8 Dockerfile docker.io/sismics/debian-java Debian Jessy + Oracle JDK docker.io/oracleinanutshell/oracle-xe-11g docker.io/oraclecoherence/coherence-ce Coherence Community Edition docker.io/oracledb19c/oracle.19.3.0-ee docker.io/oracledemo1/hello-world Test docker build from github docker.io/gvenzl/oracle-xe Oracle Database XE (21c, 18c, 11g) for every... docker.io/iamseth/oracledb_exporter A Prometheus exporter for Oracle modeled aft... [oracle@ol-node-01 ~]$
List the top 5 images from both configured container registries being used.
podman search oracle --limit 5
Note: The command is flexible with the arrangement of the command options, for example, the command
podman search --limit 5 oracle
also works.Example Output:
[oracle@ol-node-01 ~]$ podman search oracle --limit 5 NAME DESCRIPTION container-registry.oracle.com/verrazzano/keycloak-oracle-theme This image is part of, and for use with, the... container-registry.oracle.com/os/oraclelinux Oracle Linux container-registry.oracle.com/oracle_linux_automation_manager/olam-ee This image is part of and for use with the O... container-registry.oracle.com/oracle_linux_automation_manager/olam-builder This image supports Builder Utility and for... container-registry.oracle.com/middleware/oracle/shared/idmcache Oracle Advanced Authentication - Cache docker.io/library/oraclelinux Official Docker builds of Oracle Linux. docker.io/kasmweb/oracle-8-desktop Oracle Linux 8 desktop for Kasm Workspaces docker.io/kasmweb/oracle-7-desktop Oracle Linux 7 desktop for Kasm Workspaces docker.io/kasmweb/oracle-9-desktop Oracle 9 desktop for Kasm Workspaces docker.io/dokken/oraclelinux-7 Oracle Linux 7 image for kitchen-dokken [oracle@ol-node-01 ~]$
Search again for images matching
oracle
, list only the first 10 entries and additional columns showing star rating, official status, and automated information.podman search oracle --limit 10 --compatible
Example Output:
[oracle@ol-node-01 ~]$ podman search oracle --limit 10 --compatible NAME DESCRIPTION STARS OFFICIAL AUTOMATED container-registry.oracle.com/verrazzano/keycloak-oracle-theme This image is part of, and for use with, the... 0 [OK] container-registry.oracle.com/os/oraclelinux Oracle Linux 0 [OK] container-registry.oracle.com/oracle_linux_automation_manager/olam-ee This image is part of and for use with the O... 0 [OK] container-registry.oracle.com/oracle_linux_automation_manager/olam-builder This image supports Builder Utility and for... 0 [OK] 0 [OK] leware/oracle/shared/idmcache Oracle Advanced Authentication - Cache container-registry.oracle.com/middleware/oracle/shared/oaa-mgmt Oracle Advanced Authentication - Install and... 0 [OK] docker.io/library/oraclelinux Official Docker builds of Oracle Linux. 1016 [OK] docker.io/kasmweb/oracle-8-desktop Oracle Linux 8 desktop for Kasm Workspaces 3 docker.io/kasmweb/oracle-7-desktop Oracle Linux 7 desktop for Kasm Workspaces 1 docker.io/kasmweb/oracle-9-desktop Oracle 9 desktop for Kasm Workspaces 0 docker.io/dokken/oraclelinux-7 Oracle Linux 7 image for kitchen-dokken 1 docker.io/dokken/oraclelinux-6 Oracle Linux 6 image for kitchen-dokken 0 docker.io/dokken/oraclelinux-9 Oracle Linux 9 image for use with Test Kitch... 0 docker.io/paketobuildpacks/oracle 0 docker.io/dokken/oraclelinux-8 1 docker.io/vulhub/oracle 0 [oracle@ol-node-01 ~]$
List the image version tags for oraclelinux images.
You need to specify the full qualified path and image name. The default is to only list first 25 entries for each registry searched. If output is more than the default top 25 displayed per registry, you may not see all possible entries.
podman search --list-tags container-registry.oracle.com/os/oraclelinux
Example Output:
[oracle@ol-node-01 ~]$ podman search --list-tags container-registry.oracle.com/os/oraclelinux NAME TAG container-registry.oracle.com/os/oraclelinux 5.11 container-registry.oracle.com/os/oraclelinux 5 container-registry.oracle.com/os/oraclelinux 6-slim container-registry.oracle.com/os/oraclelinux 6.10 container-registry.oracle.com/os/oraclelinux 6.6 container-registry.oracle.com/os/oraclelinux 6.7 container-registry.oracle.com/os/oraclelinux 6.8 container-registry.oracle.com/os/oraclelinux 6.9 container-registry.oracle.com/os/oraclelinux 6 container-registry.oracle.com/os/oraclelinux 7-slim-amd64 container-registry.oracle.com/os/oraclelinux 7-slim-arm64v8 container-registry.oracle.com/os/oraclelinux 7-slim-fips-amd64 container-registry.oracle.com/os/oraclelinux 7-slim-fips-arm64v8 container-registry.oracle.com/os/oraclelinux 7-slim-fips container-registry.oracle.com/os/oraclelinux 7-slim container-registry.oracle.com/os/oraclelinux 7.0 container-registry.oracle.com/os/oraclelinux 7.1 container-registry.oracle.com/os/oraclelinux 7.2 container-registry.oracle.com/os/oraclelinux 7.3 container-registry.oracle.com/os/oraclelinux 7.4 container-registry.oracle.com/os/oraclelinux 7.5 container-registry.oracle.com/os/oraclelinux 7.6 container-registry.oracle.com/os/oraclelinux 7.7 container-registry.oracle.com/os/oraclelinux 7.8 container-registry.oracle.com/os/oraclelinux 7.9 [oracle@ol-node-01 ~]$
List again the image tags for
oraclelinux
images, but increase the number of entries displayed to 50.podman search --list-tags container-registry.oracle.com/os/oraclelinux --limit 50
Example Output:
[oracle@ol-node-01 ~]$ podman search --list-tags container-registry.oracle.com/os/oraclelinux --limit 50 NAME TAG container-registry.oracle.com/os/oraclelinux 5.11 container-registry.oracle.com/os/oraclelinux 5 container-registry.oracle.com/os/oraclelinux 6-slim container-registry.oracle.com/os/oraclelinux 6.10 container-registry.oracle.com/os/oraclelinux 6.6 container-registry.oracle.com/os/oraclelinux 6.7 container-registry.oracle.com/os/oraclelinux 6.8 container-registry.oracle.com/os/oraclelinux 6.9 container-registry.oracle.com/os/oraclelinux 6 container-registry.oracle.com/os/oraclelinux 7-slim-amd64 container-registry.oracle.com/os/oraclelinux 7-slim-arm64v8 container-registry.oracle.com/os/oraclelinux 7-slim-fips-amd64 container-registry.oracle.com/os/oraclelinux 7-slim-fips-arm64v8 container-registry.oracle.com/os/oraclelinux 7-slim-fips container-registry.oracle.com/os/oraclelinux 7-slim container-registry.oracle.com/os/oraclelinux 7.0 container-registry.oracle.com/os/oraclelinux 7.1 container-registry.oracle.com/os/oraclelinux 7.2 container-registry.oracle.com/os/oraclelinux 7.3 container-registry.oracle.com/os/oraclelinux 7.4 container-registry.oracle.com/os/oraclelinux 7.5 container-registry.oracle.com/os/oraclelinux 7.6 container-registry.oracle.com/os/oraclelinux 7.7 container-registry.oracle.com/os/oraclelinux 7.8 container-registry.oracle.com/os/oraclelinux 7.9 container-registry.oracle.com/os/oraclelinux 7 container-registry.oracle.com/os/oraclelinux 8-arm64v8 container-registry.oracle.com/os/oraclelinux 8-slim-arm64v8 container-registry.oracle.com/os/oraclelinux 8-slim-fips-amd64 container-registry.oracle.com/os/oraclelinux 8-slim-fips-arm64v8 container-registry.oracle.com/os/oraclelinux 8-slim-fips container-registry.oracle.com/os/oraclelinux 8-slim container-registry.oracle.com/os/oraclelinux 8.0 container-registry.oracle.com/os/oraclelinux 8.1 container-registry.oracle.com/os/oraclelinux 8.2 container-registry.oracle.com/os/oraclelinux 8.3 container-registry.oracle.com/os/oraclelinux 8.4 container-registry.oracle.com/os/oraclelinux 8.5 container-registry.oracle.com/os/oraclelinux 8.6 container-registry.oracle.com/os/oraclelinux 8.7 container-registry.oracle.com/os/oraclelinux 8.8 container-registry.oracle.com/os/oraclelinux 8 container-registry.oracle.com/os/oraclelinux 9-slim container-registry.oracle.com/os/oraclelinux 9 container-registry.oracle.com/os/oraclelinux latest [oracle@ol-node-01 ~]$
List only
oraclelinux
images with tags containing the number 8.podman search --list-tags container-registry.oracle.com/os/oraclelinux --limit 50 | grep 8
Example Output:
[oracle@ol-node-01 ~]$ podman search --list-tags container-registry.oracle.com/os/oraclelinux --limit 50 | grep 8 container-registry.oracle.com/os/oraclelinux 6.8 container-registry.oracle.com/os/oraclelinux 7-slim-arm64v8 container-registry.oracle.com/os/oraclelinux 7-slim-fips-arm64v8 container-registry.oracle.com/os/oraclelinux 7.8 container-registry.oracle.com/os/oraclelinux 8-arm64v8 container-registry.oracle.com/os/oraclelinux 8-slim-arm64v8 container-registry.oracle.com/os/oraclelinux 8-slim-fips-amd64 container-registry.oracle.com/os/oraclelinux 8-slim-fips-arm64v8 container-registry.oracle.com/os/oraclelinux 8-slim-fips container-registry.oracle.com/os/oraclelinux 8-slim container-registry.oracle.com/os/oraclelinux 8.0 container-registry.oracle.com/os/oraclelinux 8.1 container-registry.oracle.com/os/oraclelinux 8.2 container-registry.oracle.com/os/oraclelinux 8.3 container-registry.oracle.com/os/oraclelinux 8.4 container-registry.oracle.com/os/oraclelinux 8.5 container-registry.oracle.com/os/oraclelinux 8.6 container-registry.oracle.com/os/oraclelinux 8.7 container-registry.oracle.com/os/oraclelinux 8.8 container-registry.oracle.com/os/oraclelinux 8 [oracle@ol-node-01 ~]$
List only
oraclelinux
images with tags containing the number 9.podman search --list-tags container-registry.oracle.com/os/oraclelinux --limit 50 | grep 9
Example Output:
[oracle@ol-node-01 ~]$ podman search --list-tags container-registry.oracle.com/os/oraclelinux --limit 50 | grep 9 container-registry.oracle.com/os/oraclelinux 6.9 container-registry.oracle.com/os/oraclelinux 7.9 container-registry.oracle.com/os/oraclelinux 9-slim container-registry.oracle.com/os/oraclelinux 9 [oracle@ol-node-01 ~]$
List
oracle
images with official status.podman search oracle -f=is-official
Example Output:
[oracle@ol-node-01 ~]$ [oracle@ol-node-01 ~]$ podman search oracle -f=is-official NAME DESCRIPTION container-registry.oracle.com/verrazzano/keycloak-oracle-theme This image is part of, and for use with, the... container-registry.oracle.com/os/oraclelinux Oracle Linux container-registry.oracle.com/oracle_linux_automation_manager/olam-ee This image is part of and for use with the O... container-registry.oracle.com/oracle_linux_automation_manager/olam-builder This image supports Builder Utility and for... container-registry.oracle.com/middleware/oracle/shared/idmcache Oracle Advanced Authentication - Cache container-registry.oracle.com/middleware/oracle/shared/oaa-mgmt Oracle Advanced Authentication - Install and... docker.io/library/oraclelinux Official Docker builds of Oracle Linux. [oracle@ol-node-01 ~]$ [oracle@ol-node-01 ~]$
Show the additional columns to see the
OK
status, which indicates the image is the official image.podman search oracle -f=is-official --compatible
Example Output:
[oracle@ol-node-01 ~]$ podman search oracle -f=is-official --compatible NAME DESCRIPTION STARS OFFICIAL AUTOMATED container-registry.oracle.com/verrazzano/keycloak-oracle-theme This image is part of, and for use with, the... 0 [OK] container-registry.oracle.com/os/oraclelinux Oracle Linux 0 [OK] container-registry.oracle.com/oracle_linux_automation_manager/olam-ee This image is part of and for use with the O... 0 [OK] container-registry.oracle.com/oracle_linux_automation_manager/olam-builder This image supports Builder Utility and for... 0 [OK] 0 [OK] leware/oracle/shared/idmcache Oracle Advanced Authentication - Cache container-registry.oracle.com/middleware/oracle/shared/oaa-mgmt Oracle Advanced Authentication - Install and... 0 [OK] docker.io/library/oraclelinux Official Docker builds of Oracle Linux. 1018 [OK] [oracle@ol-node-01 ~]$
Limit the list to the top 3 entries for each configured registry being searched.
podman search oracle -f=is-official --compatible --limit 3
Example Output:
[oracle@ol-node-01 ~]$ podman search oracle -f=is-official --compatible --limit 3 NAME DESCRIPTION STARS OFFICIAL AUTOMATED container-registry.oracle.com/verrazzano/keycloak-oracle-theme This image is part of, and for use with, the... 0 [OK] container-registry.oracle.com/os/oraclelinux Oracle Linux 0 [OK] container-registry.oracle.com/oracle_linux_automation_manager/olam-ee This image is part of and for use with the O... 0 [OK] docker.io/library/oraclelinux Official Docker builds of Oracle Linux. 1016 [OK] [oracle@ol-node-01 ~]$
The Docker registry only returns one image found.
List any images that have currently been downloaded to local storage.
podman images
Note: The hello:latest image was used for the initial test earlier.
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/podman/hello latest e2b3db5d4fdf 2 weeks ago 82.3 kB [oracle@ol-node-01 ~]$
Pull images for containers
A container image is a read-only template that is used to generate a container. The image contains all the requirements for a service or application to run.
Images can be tagged to enable you to identify different versions of the same image. Often an image might include a default tag of latest
so that Podman users can easily identify the most recent version of the image. However, Oracle Linux images don't use this tag as it can result in significant jumps between distribution releases rather than update levels. Oracle uses a slim image or a release tag instead.
Pull the oraclelinux:8-slim image down from the Oracle container registry to your local storage.
podman pull container-registry.oracle.com/os/oraclelinux:8-slim
Note: In the command you are identifying the full path for the registry (
container-registry.oracle.com/os/
), the image name (oraclelinux
) and tag (8-slim
).Example Output:
Trying to pull container-registry.oracle.com/os/oraclelinux:8-slim... Getting image source signatures Copying blob 0216b72c8847 done Copying config 955e622938 done Writing manifest to image destination Storing signatures 955e6229383993c5cc696a857c0151f02bb4520396a993662f1505d99d7161c9
IMPORTANT: The ID values seen in your environment may be different to the examples shown (eg;
955e622938
) . Always ensure you are referencing the correct ID values in your commands.List all images downloaded.
podman images
Example Output:
REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 40 hours ago 113 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB
The
IMAGE ID
column shows the unique identifier (ID) for each image pulled down to local storage.Pull down the oraclelinux:9-slim image.
podman pull container-registry.oracle.com/os/oraclelinux:9-slim
Example Output:
Trying to pull container-registry.oracle.com/os/oraclelinux:9-slim... Getting image source signatures Copying blob 8f0005095053 done Copying config 7051f92cc6 done Writing manifest to image destination Storing signatures 7051f92cc657df99428fdf5306f3a4207227169fdfaed96437b76becaaa96fca
List all images downloaded.
podman images
Example Output:
REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 40 hours ago 113 MB container-registry.oracle.com/os/oraclelinux 9-slim 7051f92cc657 4 days ago 106 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB
Use the name oracle8slim without a container path to try to find and pull an image with this name from any of the registries configured. This is not an Oracle image name. A search of the containers will be attempted to try and find any image with this name.
You will be prompted to select a registry because the registries configuration file has two container registries configured to be searched. Up arrow/down arrow allows selection, but if you hit return you will get an authentication error. This is because you need to have login credentials to access the selected registry.
You can escape back to the prompt using the
ctrl-c
keys.podman pull oracle8slim
Example Output:
[oracle@ol-node-01 ~]$ podman pull oracle8slim ? Please select an image: ��� container-registry.oracle.com/oracle8slim:latest docker.io/library/oracle8slim:latest
For the Oracle container registry, if you have an account and Oracle Single Sign-On credentials, you would use the command
podman login container-registry.oracle.com
to access the registry. For this lab it is not necessary to do this, do not try to log in to either registry.After completing this lab, you can read more about using these registries in this documentation page Podman User's Guide - Using Container Registries
Inspect the configuration and metadata information for the oraclelinux:8-slim image. Identify the image ID, registry, and tag information in the output.
podman inspect oraclelinux:8-slim
Example Output:
[oracle@ol-node-01 ~]$ podman inspect oraclelinux:8-slim . . "Id": "955e6229383993c5cc696a857c0151f02bb4520396a993662f1505d99d7161c9", "Digest": "sha256:1d7baba8e3cef450de31a723987dd33a41d9f6afe38e1fb5a5066e60381fd238", "RepoTags": [ "container-registry.oracle.com/os/oraclelinux:8-slim" . . [oracle@ol-node-01 ~]$
Compare the
Id
field to the IMAGE ID column information in thepodman images
command output. See that the first 12 characters match the value seen inIMAGE ID
column. This is enough to identify separate images in the list.Inspect the image again using the first 4 characters of the image ID value from the
podman images
output.Use the correct partial image ID value seen in your environment. It may be different to the command and output shown.
podman inspect 955e
Note: This works with any length of unique ID characters reading from left to right. If unique enough, even
podman inspect 5
will work.With one command, pull the oraclelinux:7-slim and oraclelinux:6-slim images by separating them with a space.
podman pull container-registry.oracle.com/os/oraclelinux:7-slim container-registry.oracle.com/os/oraclelinux:6-slim
Example Output:
[oracle@ol-node-01 ~]$ podman pull container-registry.oracle.com/os/oraclelinux:7-slim container-registry.oracle.com/os/oraclelinux:6-slim Trying to pull container-registry.oracle.com/os/oraclelinux:7-slim... Getting image source signatures Copying blob 1b213d765768 done Copying config bf7f857e0a done Writing manifest to image destination Storing signatures bf7f857e0a78d95e148eece2155432a3c0cf14be7e64793605e321b4d6e4387d Trying to pull container-registry.oracle.com/os/oraclelinux:6-slim... Getting image source signatures Copying blob ca8686401c21 done Copying config 140aefca7c done Writing manifest to image destination Storing signatures 140aefca7c505ab8020f616bfc1966500969a6a9c9b4b82719b6753244aa26b0 [oracle@ol-node-01 ~]$
View all the images downloaded.
podman images
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 40 hours ago 113 MB container-registry.oracle.com/os/oraclelinux 9-slim 7051f92cc657 4 days ago 106 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB container-registry.oracle.com/os/oraclelinux 7-slim bf7f857e0a78 5 weeks ago 145 MB container-registry.oracle.com/os/oraclelinux 6-slim 140aefca7c50 2 years ago 126 MB [oracle@ol-node-01 ~]$
Use a filter to only show downloaded images with the name
oraclelinux:8-slim
in the list.podman images --filter reference=oraclelinux:8-slim
Example Output:
[oracle@ol-node-01 ~]$ podman images --filter reference=oraclelinux:8-slim REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 40 hours ago 113 MB [oracle@ol-node-01 ~]$
Remove the
oraclelinux:6-slim
image.podman rmi oraclelinux:6-slim
Example Output:
[oracle@ol-node-01 ~]$ podman rmi oraclelinux:6-slim Untagged: container-registry.oracle.com/os/oraclelinux:6-slim Deleted: 140aefca7c505ab8020f616bfc1966500969a6a9c9b4b82719b6753244aa26b0 [oracle@ol-node-01 ~]$
Remove the oraclelinux:7-slim image, do not use the name, instead use the full or partial ID.
podman rmi bf7
Example Output:
[oracle@ol-node-01 ~]$ podman rmi bf7 Untagged: container-registry.oracle.com/os/oraclelinux:7-slim Deleted: bf7f857e0a78d95e148eece2155432a3c0cf14be7e64793605e321b4d6e4387d [oracle@ol-node-01 ~]$
Note: Remember that partial ID values must start with left most character, reading left to right.
Verify both images have been removed.
podman images
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 40 hours ago 113 MB container-registry.oracle.com/os/oraclelinux 9-slim 7051f92cc657 4 days ago 106 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB [oracle@ol-node-01 ~]$
Pull down again the oralcelinux:7-slim and oraclelinux:6-slim images from the Oracle container registry.
podman pull container-registry.oracle.com/os/oraclelinux:7-slim container-registry.oracle.com/os/oraclelinux:6-slim
Example Output:
[oracle@ol-node-01 ~]$ podman pull container-registry.oracle.com/os/oraclelinux:7-slim container-registry.oracle.com/os/oraclelinux:6-slim Trying to pull container-registry.oracle.com/os/oraclelinux:7-slim... Getting image source signatures Copying blob 1b213d765768 done Copying config bf7f857e0a done Writing manifest to image destination Storing signatures bf7f857e0a78d95e148eece2155432a3c0cf14be7e64793605e321b4d6e4387d Trying to pull container-registry.oracle.com/os/oraclelinux:6-slim... Getting image source signatures Copying blob ca8686401c21 done Copying config 140aefca7c done Writing manifest to image destination Storing signatures 140aefca7c505ab8020f616bfc1966500969a6a9c9b4b82719b6753244aa26b0 [oracle@ol-node-01 ~]$
Verify they are back in your local storage.
podman images
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 41 hours ago 113 MB container-registry.oracle.com/os/oraclelinux 9-slim 7051f92cc657 4 days ago 106 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB container-registry.oracle.com/os/oraclelinux 7-slim bf7f857e0a78 5 weeks ago 145 MB container-registry.oracle.com/os/oraclelinux 6-slim 140aefca7c50 2 years ago 126 MB [oracle@ol-node-01 ~]$
Run containers
Containers are running instances of images. Each container uses an image as its starting point and then loads into run time by using the parameters that are provided when it's created or run.
Create a container using the oraclelinux:8-slim image, giving it the name
myoracle8
and using the image ID (full or partial).podman create --name myoracle8 -it 955e62293839
Note: The option
-i
will keep the STDIN open and make the container interactive, thet
will open a pseudo-tty to allow commands to be run to it. In these Oracle Linux images /bin/bash is running by default.Example Output:
[oracle@ol-node-01 ~]$ podman create --name myoracle8 -it 955e62293839 bbb97e201b35f4731c1e37f8d986513ac9b25a50a0791b8a14918dfc6e0d5f89 output
List all containers created with the
podman ps
command.podman ps
Example Output:
[oracle@ol-node-01 ~]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [oracle@ol-node-01 ~]$
No containers are listed as this command only shows running containers. Creating a container does not automatically raise its state to running unless you use a specific command option, which we will see later.
List all containers, regardless of their status, with the
-a
option.podman ps -a
Example Output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 22 minutes ago Exited (0) 22 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 53 seconds ago Created myoracle8
The container ID is listed in the first column (
CONTAINER ID
) of the output. It is a different value to the image ID seen when viewing images. Notice theSTATUS
column for the new container shows it isCreated
, but notUp
.The
NAMES
column shows the name you assigned to the container when it was built. If you do not assign a name a random name will be assigned, as you can see for the hello:latest container (relaxed_mendeleev
) which was created in the test after installing Podman. Your environment will show different random names.Note: The container IDs seen in your environment will be different to those shown in the commands and example outputs. They are unique to when the container is created.
Create the container again with the same name.
podman run --name myoracle8 -it 955e
Example Output:
[oracle@ol-node-01 ~]$ podman run --name myoracle8 -it 5bec Error: creating container storage: the container name "myoracle8" is already in use by bbb97e201b35f4731c1e37f8d986513ac9b25a50a0791b8a14918dfc6e0d5f89. You have to remove that container to be able to reuse that name: that name is already in use [oracle@ol-node-01 ~]$
You can create and run multiple containers from the same image, but each container must have a unique name.
Start the container using a full or partial container ID to identify the container being started.
Note: Take care NOT to accidentally use the image ID. The container ID is different and found in the first column (CONTAINER ID) of the
podman ps
command.podman start bbb9
Example Output:
[oracle@ol-node-01 ~]$ podman start bbb9 bbb9 [oracle@ol-node-01 ~]$
Examine the status of the container. The status is now
Up
.podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 25 minutes ago Exited (0) 25 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 3 minutes ago Up 35 seconds myoracle8 [oracle@ol-node-01 ~]$
Create another container called my2ndol8 using the
run
command and the oraclelinux:8-slim image ID. This creates the container and also starts it.podman run --name my2ndol8 -it 955e
You are placed at a prompt in the running container.
Show the Oracle Linux version used in the container with the command
cat /etc/oracle-release
.Exit out of the container with the command
exit
.Example Output:
[oracle@ol-node-01 ~]$ podman run --name my2ndol8 -it 955e bash-4.4# bash-4.4# cat /etc/oracle-release Oracle Linux Server release 8.8 bash-4.4# exit exit [oracle@ol-node-01 ~]$
Check the status of all containers.
podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 28 minutes ago Exited (0) 28 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 6 minutes ago Up 3 minutes myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 54 seconds ago Exited (0) 39 seconds ago my2ndol8 [oracle@ol-node-01 ~]$
Exiting causes the container to stop, but it is not deleted, and can be started again, we will see this later. The
CREATED
column shows when the container was built, andSTATUS
shows the time since it was stopped (Exited
).Stop the myoracle8 container. Use the container name or ID in the command.
podman stop myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman stop myoracle8 myoracle8 [oracle@ol-node-01 ~]$
Verify the state of the container.
podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 29 minutes ago Exited (0) 29 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 7 minutes ago Exited (0) 12 seconds ago myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 2 minutes ago Exited (0) About a minute ago my2ndol8 [oracle@ol-node-01 ~]$
Start the myoracle8 container without opening a command prompt to it.
podman start myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman start myoracle8 myoracle8 [oracle@ol-node-01 ~]$
Verify it has been started.
podman ps
The STATUS column shows
Up
and how long the container has been up. Remember we can also use the-a
option to see all containers and their status.Example Output:
[oracle@ol-node-01 ~]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 9 minutes ago Up 14 seconds myoracle8 [oracle@ol-node-01 ~]$
Attach to the myoracle8 container to access its running shell prompt.
podman attach myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman attach myoracle8 bash-4.4#
Exit from the container.
exit
Example Output:
bash-4.4# exit exit [oracle@ol-node-01 ~]$
Verify that using
exit
has also resulted in a container being stopped.podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 32 minutes ago Exited (0) 32 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 10 minutes ago Exited (0) 6 seconds ago myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 4 minutes ago Exited (0) 4 minutes ago my2ndol8 [oracle@ol-node-01 ~]$
Start the myoracle8 container again, and with the same command access its shell.
podman start --attach myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman start --attach myoracle8 bash-4.4#
Exit the container without stopping it by pressing
ctrl-p
thenctrl-q
.Example Output:
bash-4.4# [oracle@ol-node-01 ~]$
Check the status of the container and verify it is still up and running.
podman ps -a
Example Output:
bash-4.4# [oracle@ol-node-01 ~]$ [oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 33 minutes ago Exited (0) 33 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 11 minutes ago Up 16 seconds myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 6 minutes ago Exited (0) 5 minutes ago my2ndol8 [oracle@ol-node-01 ~]$
Pause the myoracle8 container.
Pausing a container temporarily halts its operation. It freezes all the running processes inside a container, in their current state.
However, shutting down and restarting the host system running the paused container will not preserve the state of those processes. You can pause and unpause only while the host system remains running.
podman pause myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman pause myoracle8 myoracle8 [oracle@ol-node-01 ~]$
Note: You can pause multiple containers with the command by listing each separated by a space, or all containers by using the
-a
option.Verify the container status is paused.
podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 34 minutes ago Exited (0) 34 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 12 minutes ago Paused myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 7 minutes ago Exited (0) 6 minutes ago my2ndol8 [oracle@ol-node-01 ~]$
Resume the paused container and check its status.
podman unpause myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman unpause myoracle8 myoracle8 [oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 35 minutes ago Exited (0) 35 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 13 minutes ago Up 2 minutes myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 8 minutes ago Exited (0) 7 minutes ago my2ndol8 [oracle@ol-node-01 ~]$
Execute a command in the running myoracle8 container.
podman exec myoracle8 cat /etc/oracle-release
Example Output:
[oracle@ol-node-01 ~]$ podman exec myoracle8 cat /etc/oracle-release Oracle Linux Server release 8.8 [oracle@ol-node-01 ~]$
You can also add commands to be executed to the
podman create
andpodman run
commands when creating or spinning up a new container.Practice the command again, this time using the partial container ID instead of its name.
podman exec bbb9 cat /etc/passwd
Example Output:
[oracle@ol-node-01 ~]$ podman exec bbb9 cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin [oracle@ol-node-01 ~]$
Stopping a container
Stop the running
myoracle8
container.podman stop myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman stop myoracle8 myoracle8 [oracle@ol-node-01 ~]$
By default, containers are stopped with SIGTERM. The
stop
command will by default wait 10 seconds before using SIGKILL to forcibly stop the container. The order of the running processes inside the container and the types of processes can affect how the container shuts down and how long it may take. For example many shells ignore the SIGTERM signal used when stopping a container.You can override the wait time with the
--time <secs>
option. And shortly you will use different signal to stop a container.Start a new container called myoracle9 using the oraclelinux:9-slim image ID, using the
-d
option to run it in the background and not attach to it when started.podman run -dt --name myoracle9 7051
Example Output:
[oracle@ol-node-01 ~]$ podman run -dt --name myoracle9 7051 ae59cfa770911df0eb32dcf5ad7a5e8a66565470494cd9ec3eca869945100f23 [oracle@ol-node-01 ~]$
Stop the container.
podman stop myoracle9
Example Output:
[oracle@ol-node-01 ~]$ podman stop myoracle9 WARN[0010] StopSignal SIGTERM failed to stop container myoracle9 in 10 seconds, resorting to SIGKILL myoracle9 [oracle@ol-node-01 ~]$
A warning is presented after 10 seconds, the container has not been stopped with SIGTERM, and after the default timeout is stopped with SIGKILL. The shell running in the container prevented the SIGTERM stopping it.
Run a new container called mynew9 and use the
--stop-signal=SIGHUP
option to change the stop signal to SIGHUP whenever the container is stopped.podman run -dt --stop-signal=SIGHUP --name mynew9 7051
Example Output:
[oracle@ol-node-01 ~]$ podman run -dt --stop-signal=SIGHUP --name mynew9 7051 d37cc3938e4a560164510ecfe46749edc423071b32cf6361bd1350c9c929aa35 [oracle@ol-node-01 ~]$
Stop the container.
podman stop mynew9
Example Output:
[oracle@ol-node-01 ~]$ podman stop mynew9 myoracle9 [oracle@ol-node-01 ~]$
The container stops without timing out.
Let's see another way to stop the container. Run another container called my2nd9 using the oraclelinux:9-slim image ID in background without attaching to it.
podman run -dt --name my2nd9 7051
Example Output:
[oracle@ol-node-01 ~]$ podman run -dt --name my2nd9 7051 1c66cdd34762c892aef9651128e4f1ae9165dbf51376c75b4a3482d1b78ea678 [oracle@ol-node-01 ~]$
Stop the container with the
kill
command optionpodman kill my2nd9
Example Output:
[oracle@ol-node-01 ~]$ podman kill my2nd9 my2nd9 [oracle@ol-node-01 ~]$
The container stops without timeout or warning.
View the container status.
podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... 48 minutes ago Exited (0) 48 minutes ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 26 minutes ago Exited (0) 6 minutes ago myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 21 minutes ago Exited (0) 21 minutes ago my2ndol8 ae59cfa77091 container-registry.oracle.com/os/oraclelinux:9-slim /bin/bash 5 minutes ago Exited (137) 4 minutes ago myoracle9 d37cc3938e4a container-registry.oracle.com/os/oraclelinux:9-slim /bin/bash 3 minutes ago Exited (129) 2 minutes ago mynew9 1c66cdd34762 container-registry.oracle.com/os/oraclelinux:9-slim /bin/bash 2 minutes ago Exited (137) 10 seconds ago my2nd9 [oracle@ol-node-01 ~]$
View container logs
Start and attach to the myoracle8 container.
- Run the
cat /etc/oracle-release
andwhoami
commands on the prompt and then exit.
podman start --attach myoracle8
Example Output:
[oracle@ol-node-01 ~]$ podman start --attach myoracle8 bash-4.4# cat /etc/oracle-release Oracle Linux Server release 8.8 bash-4.4# bash-4.4# whoami root bash-4.4# exit exit [oracle@ol-node-01 ~]$
- Run the
Start and attach to the mynew9 container.
- Run the
cat /etc/oracle-release
andcat /etc/passwd
commands on the prompt and then exit.
podman start --attach mynew9
Example Output:
[oracle@ol-node-01 ~]$ podman start --attach mynew9 bash-5.1# cat /etc/oracle-release Oracle Linux Server release 9.2 bash-5.1# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin bash-5.1# exit exit [oracle@ol-node-01 ~]$
- Run the
View the log for the myoracle8 container.
You see any logs available for the container at the time of running the command.
podman logs myoracle8
Example Output
[oracle@ol-node-01 ~]$ podman logs myoracle8 bash-4.4# exit bash-4.4# exit exit bash-4.4# exit bash-4.4# cat /etc/oracle-release Oracle Linux Server release 8.8 bash-4.4# whoami root bash-4.4# exit exit [oracle@ol-node-01 ~]$
Note: Your logs information may be different depending on what commands you have run on the shell prompt.
With the same command view the logs for the myoracle8 and mynew9 containers.
podman logs myoracle8 mynew9
Example Output:
[oracle@ol-node-01 ~]$ podman logs myoracle8 mynew9 bbb97e201b35 bash-4.4# exit 1c66cdd34762 bash-5.1# 1c66cdd34762 bash-5.1# bash-4.4# bbb97e201b35 bash-4.4# bbb97e201b35 bash-4.4# exit bbb97e201b35 exit 1c66cdd34762 bash-5.1# cat /etc/oracle-release Oracle Linux Server release 9.2 1c66cdd34762 bash-5.1# cat /etc/passwd root:x:0:0:root:/root:/bin/bash 1c66cdd34762 bin:x:1:1:bin:/bin:/sbin/nologin 1c66cdd34762 daemon:x:2:2:daemon:/sbin:/sbin/nologin 1c66cdd34762 adm:x:3:4:adm:/var/adm:/sbin/nologin 1c66cdd34762 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin 1c66cdd34762 sync:x:5:0:sync:/sbin:/bin/sync 1c66cdd34762 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown 1c66cdd34762 halt:x:7:0:halt:/sbin:/sbin/halt 1c66cdd34762 mail:x:8:12:mail:/var/spool/mail:/sbin/nologin 1c66cdd34762 operator:x:11:0:operator:/root:/sbin/nologin 1c66cdd34762 games:x:12:100:games:/usr/games:/sbin/nologin 1c66cdd34762 ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin 1c66cdd34762 nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin 1c66cdd34762 bash-5.1# exit exitcdd34762 bbb97e201b35 bash-4.4# exit bbb97e201b35 bash-4.4# exit bbb97e201b35 exit bbb97e201b35 bash-4.4# cat /etc/oracle-release bbb97e201b35 Oracle Linux Server release 8.8 bbb97e201b35 bash-4.4# bbb97e201b35 bash-4.4# whoami bbb97e201b35 root bbb97e201b35 bash-4.4# exit bbb97e201b35 exit [oracle@ol-node-01 ~]$
The output includes the container ID values (Eg;
1c66cdd34762
andbbb97e201b35
) to identify which container the entry is from.
Remove containers and images
First let's see about removing containers.
Remove the myoracle9 container.
podman rm myoracle9
Note: As usual, you can use the name or container ID in the command.
Verify the container was removed.
podman ps -a
Example Output:
[oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c9b8db997ad quay.io/podman/hello:latest /usr/local/bin/po... About an hour ago Exited (0) About an hour ago relaxed_mendeleev bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 43 minutes ago Exited (0) 11 minutes ago myoracle8 00bbe87d6cff container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 38 minutes ago Exited (0) 37 minutes ago my2ndol8 d37cc3938e4a container-registry.oracle.com/os/oraclelinux:9-slim /bin/bash 20 minutes ago Exited (129) 19 minutes ago mynew9 1c66cdd34762 container-registry.oracle.com/os/oraclelinux:9-slim /bin/bash 18 minutes ago Exited (137) 16 minutes ago my2nd9 [oracle@ol-node-01 ~]$
Remove the containers my2ndol8 using its name, and the hello:latest using its ID in a single command.
podman rm my2ndol8 9c9b
Example Output:
[oracle@ol-node-01 ~]$ podman rm my2ndol8 9c9b my2ndol8 9c9b [oracle@ol-node-01 ~]$
Start the container mynew9.
podman start mynew9
Example Output:
[oracle@ol-node-01 ~]$ podman start mynew9 mynew9 [oracle@ol-node-01 ~]$
Remove the container mynew9.
podman rm mynew9
Example Output:
[oracle@ol-node-01 ~]$ podman rm mynew9 Error: cannot remove container d37cc3938e4a560164510ecfe46749edc423071b32cf6361bd1350c9c929aa35 as it is running - running or paused containers cannot be removed without force: container state improper [oracle@ol-node-01 ~]$
Use the
--force
option to remove the running mynew9 container without first using thestop
option.podman rm --force mynew9
Example Output:
[oracle@ol-node-01 ~]$ podman rm --force mynew9 mynew9 [oracle@ol-node-01 ~]$
Note: Forcing a container removal can also be used to remove containers that are created by different container engines, even if the container is not known to Podman.
Create a new container called mynewol8 from the oraclelinux:8-slim image and have it automatically removed whenever it is stopped.
Run the new container.
podman run --rm --name mynewol8 -dt 955e
Example Output:
[oracle@ol-node-01 ~]$ podman run --rm --name mynewol8 -dt 955e ed7a65fa9b96dafa91ce9a07e46e48629f7797d8dd316c0f7ee68cfa4f8b0fd3 [oracle@ol-node-01 ~]$
Verify it is created and running.
Example Output:
[oracle@ol-node-01 ~]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ed7a65fa9b96 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 58 seconds ago Up 59 seconds mynewol8 [oracle@ol-node-01 ~]$
Stop the container.
podman stop mynewol8
Example Output:
[oracle@ol-node-01 ~]$ podman stop mynewol8 mnewol8 [oracle@ol-node-01 ~]$
Verify it has been removed from the container list.
Run the same container again.
podman run --rm --name mynewol8 -dt 955e
Example Output:
[oracle@ol-node-01 ~]$ podman run --rm --name mynewol8 -dt 955e 894fe73bcb0ce240fa567bb6765f521b094ff01c8f8599dca0b8a630a424a642 [oracle@ol-node-01 ~]$
Attach to its shell prompt.
podman attach mynewol8
Exit out again and check the container list.
exit
Example Output:
[oracle@ol-node-01 ~]$ podman attach mynewol8 bash-4.4# exit exit [oracle@ol-node-01 ~]$ [oracle@ol-node-01 ~]$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bbb97e201b35 container-registry.oracle.com/os/oraclelinux:8-slim /bin/bash 51 minutes ago Exited (0) 20 minutes ago myoracle8 1c66cdd34762 container-registry.oracle.com/os/oraclelinux:9-slim /bin/bash 26 minutes ago Exited (137) 24 minutes ago my2nd9 [oracle@ol-node-01 ~]$
The container is also removed after exiting with the
exit
command from the shell prompt.Remove the remaining containers with the
-a
option.podman rm -a
Example Output:
[oracle@ol-node-01 ~]$ podman rm -a bbb97e201b35f4731c1e37f8d986513ac9b25a50a0791b8a14918dfc6e0d5f89 1c66cdd34762c892aef9651128e4f1ae9165dbf51376c75b4a3482d1b78ea678 [oracle@ol-node-01 ~]$
Verify all containers are removed.
Now let's remove images from local storage.
List the downloaded images available.
podman images
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 41 hours ago 113 MB container-registry.oracle.com/os/oraclelinux 9-slim 7051f92cc657 4 days ago 106 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB container-registry.oracle.com/os/oraclelinux 7-slim bf7f857e0a78 5 weeks ago 145 MB container-registry.oracle.com/os/oraclelinux 6-slim 140aefca7c50 2 years ago 126 MB [oracle@ol-node-01 ~]$
Remove the oraclelinux:6-slim image using the image name.
podman rmi oraclelinux:6-slim
Example Output:
[oracle@ol-node-01 ~]$ podman rmi oraclelinux:6-slim Untagged: container-registry.oracle.com/os/oraclelinux:6-slim Deleted: 140aefca7c505ab8020f616bfc1966500969a6a9c9b4b82719b6753244aa26b0 [oracle@ol-node-01 ~]$
Remove the oraclelinux:7-slim image using its ID.
podman rmi bf7f
Example Output:
[oracle@ol-node-01 ~]$ podman rmi bf7f Untagged: container-registry.oracle.com/os/oraclelinux:7-slim Deleted: bf7f857e0a78d95e148eece2155432a3c0cf14be7e64793605e321b4d6e4387d [oracle@ol-node-01 ~]$
Verify the images are removed.
podman images
Example Output:
[oracle@ol-node-01 ~]$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/os/oraclelinux 8-slim 955e62293839 41 hours ago 113 MB container-registry.oracle.com/os/oraclelinux 9-slim 7051f92cc657 4 days ago 106 MB quay.io/podman/hello latest e2b3db5d4fdf 3 weeks ago 82.3 kB [oracle@ol-node-01 ~]$
Remove all remaining images with the
-a
option.podman rmi -a
Example Output:
[oracle@ol-node-01 ~]$ podman rmi -a Untagged: quay.io/podman/hello:latest Untagged: container-registry.oracle.com/os/oraclelinux:8-slim Untagged: container-registry.oracle.com/os/oraclelinux:9-slim Deleted: e2b3db5d4fdf670b56dd7138d53b5974f2893a965f7d37486fbb9fcbf5e91d9d Deleted: 955e6229383993c5cc696a857c0151f02bb4520396a993662f1505d99d7161c9 Deleted: 7051f92cc657df99428fdf5306f3a4207227169fdfaed96437b76becaaa96fca [oracle@ol-node-01 ~]$
Verify all images in local storage have been removed.
Summary
To recap, in this lab you practiced the following:
- Installing Podman on your system
- Verifying the preconfigured image registries
- Searching for and pulling down various images to be used for containers
- Creating and running containers
- Starting, stopping and attaching to containers
- Viewing container logs
- Removing containers
- Removing images