Welcome to this video about using Podman to run containers on Oracle Linux.
Containers are running instances of images.
An image is a non-changeable file containing a minimal operating system, libraries, source
code, tools, and other files needed to run applications.
A container is the virtualized run-time instance of an image.
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.
We can create a container based on an image downloaded to local storage, or it will be
pulled from the container registry and used when the container is created.
To learn about searching container registries and pulling images to local storage you can
find more about each of these topics in these other available free videos.
Search Container Registries with Podman on Oracle Linux.
And Pull Images with Podman on Oracle Linux.
And to read more about creating and running containers, checkout the documentation at
this link, in the Managing Containers section of the chapter Working With Images, Containers,
and Pods.
So let's look at running some containers.
In preparation I have already downloaded a number of images to our local storage.
To view downloaded images we use the command podman images.
We have four Oracle slim images and a general test image for podman called hello.
Let's create a container using the oraclelinux image with the tag 8-slim, giving it the name
myoracle8 and identifying the image to use with its image ID.
The image ID can be the full ID from the image list, or enough of it reading from left to
right to uniquely identify it from the others.
We use the command podman create --name myoracle8 -it and for this first time the full ID value
from the IMAGE ID column.
The option -i will keep the standard input open and make the container interactive, the
t will open a pseudo-tty to allow commands to be run to it.
In these Oracle Linux images the bash shell is run by default, so there is no need to
add it to the command.
And now we use the command podman ps to list any running containers.
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.
So let's list all containers, regardless of their status, with the -a option.
The unique container ID is listed in the first column of the output.
A new value is used each time a container is created, even if you are creating the same
container again.
Note that these IDs are different values to ones used for image IDs.
The STATUS column for the new container shows it is Created, but not Up, so it's not currently
running.
The NAMES column shows the name you assigned to the container when it was built.
If we don't assign a name a random name will be assigned, as you can see for the hello
container which was created before the start of this demonstration.
Let's try to create the container again with the same name.
The error states that that name is already used.
We can create and run multiple containers from the same image, but each container must
have a unique name.
As the myoracle8 container is only created it is not up and running.
We start the container with the command podman start, this time using the partial container
ID to identify the container being started.
Remember to take care to not accidentally use the image ID by mistake, the image and
container IDs are not related to each other.
We can examine the status of all containers with the command podman ps, we are able to
just use podamn ps because the container is running.
We see the status is up.
Let's create another container called my2ndol8 but this time using the run command, again
using the oraclelinux 8-slim image ID.
This will create the container, but the command also starts it.
We use the command podman run --name my2ndol8 -it dd26.
When it starts, it places us at a shell prompt in the running container.
The running container provides an interactive bash shell prompt based on the command passed
during its creation.
To interact with the container we can show the Oracle Linux version used in the container
with the command cat /etc/oracle-release.
And can also run the commands whoami and uname -a.
We exit out of the container with the command exit.
Exiting causes the container to stop, but it is not deleted, and can be started again.
We check the status of the container, as the container is stopped by exiting, we must use
the command podman ps -a.
The CREATED column shows when the container was built, and STATUS shows the time since
it was stopped and its state identified as EXITED.
Now let's stop the still running myoracle8 container with the command podman stop myoracle8.
And verify again the state of the container.
This time let's start the same container without opening a shell prompt on it, by using the
command podman start myoracle8.
We verify it has been started.
The STATUS column shows Up and for how long the container has been up when the command
was run.
With it started we can attach to the container to access its running shell prompt with the
command podman attach myoracle8.
Let's exit again from the container.
And verify that using exit has also resulted in the container being stopped.
Now let's start the container again, but with the same command also access its shell, we
use the command podman start --attach myoracle8.
This time we exit the container without stopping it by pressing ctrl-p then ctrl-q.
And checking the status verifies it is still up and running.
Now let's pause the myoracle8 container.
Pausing a container temporarily halts its operation and 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.
We use the command podman pause myoracle8.
Like many commands, you can pause multiple containers with the same command by listing
each separated by a space, or even all containers by using the -a option.
We verify the container status is paused.
To resume the paused container, we use the command podman unpause myoracle8.
And check its status.
We can execute a command in a running container without the need to open its shell prompt.
Let's do this for the running myoracle8 container with the command podman exec myoracle8 cat
/etc/oracle-release.
You can also add commands to be executed to the podman create and podman run commands
when creating or spinning up a new container.
Let's practice the command again, first view the containers available, then use the command
podman exec using the partial container ID instead of its name.
As with many commands the commands to start stop pause unpause containers also work with
multiple containers.
Lets list the images again.
And now we create a third container with the oraclelinux 9-slim tagged image.
Let's list all the containers again.
Now we can start the my2ndol8 and myoracle9 containers with the command podman start and
separate the container names or IDs with a space.
And verify both containers are now started.
So that's some practice at some of the commands used to create, run, and interact with containers
using Podman.
These commands support a lot more options which are worth investigating, if you have
the time there is even a free real hands on lab environment where you can practice these
and many more Podman commands.
You can find it at this link.
That's the end of this video.
Oracle provides an extensive number of resources which you can use to learn about this subject
and others.
Use the links here to find more content about this video as well as Oracle Linux and using
Linux.
Thanks for watching.