So how do you run a container?
To run a container, first you need
to find the fully qualified name of the container.
And a convenient way to do so is by using Popman Search.
Popman Search will search the registries
that are specified as the search registries
in the registries.conf file.
Alternatively, you might also visit the registry website
to get the image FQCN from there.
Let me show you.
So when I would use Popman Search,
Nginx, for instance,
then it's going to search all the registries
and it prints a list of what it has found.
And there, make your choice.
So we have registry.access.redhat.com,
which is listed first,
because these are the supported images.
Red Hat recommends that you use those.
There is registry.redhat.io.
And there is docker.io as well.
Even if Red Hat has moved away from Docker
as the utility to run containers,
docker.io is unavoidable
because there is so very much available.
So there's another option to get information
about your containers,
and that will be the registry website.
So let me start a browser.
And on the browser, go to hub.docker.com.
That's the website for the Docker registry.
So there you see a lot of information,
and feel free to scroll down or search the website.
So I'm going to search for Nginx.
I like using Nginx.
It's a very commonly used web server,
and as you can see, it had 10 million pulls last week,
so it's quite popular.
Now, when you go to the registry,
when you go to the registry website,
it offers a benefit,
and the benefit is that you can get more information
about it.
So here we can see that it's the official build of Nginx.
And if you click the image,
then you can read what is going on.
Depending on what the creator of the container image
has decided to put in there,
this can be very useful information,
giving a lot of details about how to run the application.
And that's why I would always recommend
you visit the registry website as well
to get more information.
So once you have found your container image,
you use potman run to run the container image.
And that will search for the image
in the container registries.
If found, it will pull the image and run the container.
And containers run in the foreground by default.
If you don't like your container to run in the foreground,
give it potman run minus D to run it in the background.
Let me show you what that is doing
when you are using potman run minus D docker.io
slash library slash Nginx.
So if, for instance, you want to run Nginx,
which is a daemon-like process
and normally would occupy your console,
use potman run minus D to run it in the background.
Or you can use potman run minus IT.
That will run an interactive shell.
And this interactive shell allows you
to do work in your container.
So potman run minus IT docker.io slash library slash BusyBox
is opening a shell on BusyBox.
BusyBox is a minimal container image
that is used a lot to build custom applications.
Let me show you.
So what happens when I use potman run docker.io
slash library slash Nginx without anything?
Well, we can see that it pulls the docker image.
That means that it is downloading it right now.
And this image is downloaded in different layers.
And the nice thing about all these layers
is that all the container images might be using the same layers
and then you only have to download them once.
And then what's happening?
Well, here you are looking at the output
of the main Nginx process in a container image
because we didn't use docker run minus D.
Fortunately, if you use Control-C,
you can terminate the container and you can try it again.
So let's try it again using potman run minus D
on docker.io slash library slash Nginx.
You'll see that this time it's very fast.
That's because it doesn't have to download the container
image anymore.
Normally, when you run a command potman run
and you specify the container image,
it will check for the latest version of the container image.
And as long as no newer version of the container image
is available, you don't have to pull the container image again.
Let me also show you a potman run minus IT docker.io slash
library slash BusyBox.
And then it's pulling the BusyBox image
because I haven't used it before on this system.
And then it's opening a root shell.
Why is that?
Well, that is because this is BusyBox.
And BusyBox is a minimized, cloud-optimized Linux
distribution that was tailor-made for running
in a containerized environment.
And here you get the shell to BusyBox.
And in that shell, you can use commands,
as long as these commands are available.
So when I use PSAUX, for instance,
so you can see there's only two commands.
And that is because a container is a minimized environment.
It's not a complete operating system like a virtual machine.
And when I use exit, I can get out of there.
Now, talking about getting out of there, as I mentioned,
one of the nice features about Potman
is the rootless container.
So why am I in a root shell?
I shouldn't.
So let me run these two commands again from a non-root shell.
And then we are going to check out what happens.
So Potman run docker.io slash library slash nginx
is what I want to do.
And oops, are we forgetting something?
Yeah, I'm forgetting minus d.
Now, let me show you something.
Look carefully.
Trying to pull docker.io, that's the first thing.
I'm in a different user environment.
And every user has its own collection of container images.
So it's pulling the container image.
And then we can see this magical message,
docker entry point exec minus d command not found,
or minus d not found.
What is going on?
Well, what is going on is that the minus d
is after the name of the container image.
And anything you specify after the name of the container image
is interpreted as something that must be started
by this container main application.
So it is looking for the minus d command, and that didn't work.
And you know what's going on.
Minus d is an option that specifies how
Potman run should do its work.
And options that modify the behavior of Potman run
should always be behind run and before the name
of the container image.
So here is how you run it in the background.
And let me do the same for the busy box one.
Potman run minus it docker.io slash library slash busy box.
That would run it in the foreground
after pulling the image.
Because again, we are in the rootless environment now,
different user.
So this user needs to collect its own images.
And now I'm in the shell.
And that's still a root shell.
And in case you are wondering, hey, rootless,
but I'm in a root shell.
How is this a root shell?
Well, containers are used in a namespace environment.
And namespaces is all about isolation.
So yeah, congratulations.
You are a root within this container.
But on the host operating system,
you're only a user student.
We'll talk about that much more in the next lesson.
For now, I'm going to use Control-P, Control-Q
to put this container image in the background.
And we need to get back to the slide
so that I can explain some more details.
So you have just seen how we can run containers using Potman run.
Maybe you also want to check what's going on.
Potman ps is the command that helps you to do so.
And if you do not see your container image,
use Potman ps minus a.
Because that will show you all containers
that are currently running, but also containers that
have been running in the past.
And if you want to see properties of your container
with much details, use Potman inspect.
That will show you what is happening
inside the image or the container.
Let me show you.
So let me start with Potman ps.
There we go, all the running containers.
Where we can see the container ID?
Well, honestly, it's only the first part of the container ID,
because the container ID itself is a lot longer.
You can use the container ID for managing.
You can also use the automatically generated name,
like Loving, Ardinelli, or Upbeat, Bernal, or whatever.
Here we see the image that was used.
We see the main command that was executed in the container
when it was created, and what the current status is.
And you can see if it has any ports that are running.
That's a port that's only running within the container.
So this does not mean that if you access port 80
on this current host, you get access to the container.
We'll talk about accessing container workloads later.
Now, do we see a difference if I use Potman ps minus A?
Yeah, here we see a difference.
This was the failing attempt where
I put the minus D behind the name of the container image.
So it interpreted it really as if minus D was the command.
And there I can see that it has been created,
and it was exited with an exit status 127.
Exit status is used by applications
to communicate how well they have done
to the parent operating system.
And if the exit status is not zero,
then something has gone wrong.
Now, the interesting thing is that this faulty container
has its own container ID.
And this container here has its own container ID as well.
Now, let me show you what that means.
I'm going to use sudo find on dot minus name.
And then I'm using enough of the container ID to find it.
Let's not forget the wildcard.
And there you can see that it has created a directory.
Local dot local share container storage overlay containers.
And likewise, if we do a find on the other one, the CB345,
there you can see that CB345 has its own directory.
Every time you run a container, it
creates a container environment.
And in this container environment,
it creates a container temporary storage.
And everything else that relates to the container.
And that means that if you run containers a lot,
you'll end up with a lot of these temporary directories
that are all consuming disk space.
And at one point, sooner or later,
you might run out of disk space.
So be careful.
And maybe every now and then, you
should also remove containers using popmanrm.
So when I use popmanrm on 58c, that
is enough of the ID of the container to recognize it.
And then I use popman ps minus a.
We can't see it anymore.
And that is because the temporary environment
of the container has been cleaned up.
Let me also show you popman inspect.
So popman inspect on CB345 is showing me what?
Showing me all the properties of the container.
So if you want to know in detail what
is going on with your container, popman inspect is showing it.
Here we see the so-called entry point application.
Many of these containers run an application with the name
docker-entrypoint.sh.
And as arguments, you specify what
exactly should be happening.
So the entire configuration of the container
will be shown if you use popman inspect, which is, by the way,
also a command that you can use on container images
to find what's going on in the image.