In this lesson,
we're going to cover some basic container operations
that you should be aware of to manage your containers
and conduct basic container image operations.
First, let's jump into our container image operations.
To work with a container image,
you can use a program like Docker or Podman
to run a manage containers and container images.
Now, Podman is a containerization program
that runs on Red Hat Enterprise Linux,
and supports just about all the features
you're going to find in Docker,
without needing the underlying Docker service
or an active container engine on your system.
When it comes to issuing commands,
the same syntax is used for both Docker and Podman,
so you can choose which one you prefer to use,
and the commands that I'm going to cover in this lesson
are going to work equally well with both of them.
When you're performing container image operations,
you need to understand how to do some basic functions,
things like building, pushing, pulling,
listing and removing container images.
To build a container image,
you're going to issue the command podman build.
And this will build a container image
using a Docker file instruction
that's located in the current directory.
To push a container image to a specified destination,
you're going to enter the command podman push.
This destination could be any container management service
that you're going to use, such as Docker or Kubernetes.
To pull a container image from a container registry,
you're going to enter the command podman pull.
This registry could be a public or private registry,
as long as you have the proper access rights
and network productivity to that given registry.
To list out the container images available
on your local system, you can do this
by entering the command podman images.
If you want to list out all of the running containers,
on the other hand, you can enter podman ps -a
to list out all the running containers on your screen.
If you want to remove a container image, you can do this
by entering the command pod man rmi and the image ID.
This will then remove the container image
from the current list of containers
available on your system.
Now, as a reminder, all the podman commands that I went over
are just a subset of the long list of commands
that you can use to work with containers,
depending on your use case.
To learn more about Podman,
you can always check the man pages on your Linux system.
Also, remember that Podman uses
the exact same syntax as Docker,
and so you can easily replace the word podman
with the word Docker and all these commands
we just discussed will work inside of Docker, too.
Next, let's talk about container management
and how you can perform some basic container operations,
like starting and stopping containers,
inspecting containers, listing containers,
deploying existing images, connecting to containers,
logging actions inside of containers
and exposing ports for your containers.
First, we have the starting and stopping of containers.
If you want to start a container, simply enter the command
podman start, and the name of the container image
that you want to start.
If you want to stop a container, simply enter podman stop,
and the name of the container image that you want to stop.
Second, we have inspecting containers.
Now, to inspect a container, you simply enter
podman inspect, and the name of the container image.
This will then display the configuration
of a given container or image
so that you can ensure it's properly set up
and configured for your particular use case.
Third, we have listing containers.
To list out all the containers on your system,
you can use podman pod list
and this is going to show the containers,
their current status, such as running or paused,
and when they were first created.
Fourth, we have deploying existing images.
Now, the best way to deploy an image is to use a template
in order to give your users a quick and easy way
to deploy an image with a working configuration.
A template file is going to be created
based on the format of the containerization solution
that you're going to be using, such as OpenShift or Kubernetes.
And this will include a unique user-friendly name,
as well as descriptions of the containers
and the pods that are being used by that image.
Fifth, we have connecting to containers.
Now, if you want to connect to a container to interact with it
you can use the podman attach command
and then the container's image name.
This will attach your console
to a running container based on its name or ID
and then allow you to view its ongoing output
or interactively take control of that container.
Sixth, we have logging actions and containers.
Now, inside of your containers
there is logging that's happening by default,
but you have to get those logs
from the container to be able to read them.
To gather the logs from a container,
you can enter podman logs and the container's name
to view and collect those logs.
Seventh, we have exposing ports for your containers.
Now, if you enter podman port and the container name,
you're going to see a list of all the port mappings
for a given container.
To expose a port on a container,
you can do this when you initially create that container
using the podman create command
and using the --expose=port option
where the port contains the port number or port numbers
that you want to expose to redirection by that host system.
If you want to expose a port on a container
when you start it up or you run it,
you can instead enter podman run --expose=port.
Now, for the exam, you do not have to be an expert
in conducting container operations,
but you should understand the basics
that we covered in this lesson.
For example, if I asked you how to download
a container image from a container registry using Podman,
you should select the answer that contains
the podman pull command, because this is used
to pull or download an image from a registry.
This is the level of depth that you need to have
in order to answer questions on the exam
about basic container operations.