Let's talk about some basic container management tasks.
When it is started with Popman Run,
the container runs its default command.
And you can run an alternative command in many cases as well.
And it can often be specified as a command line argument.
Use, for instance, Popman Run UBI8 sleep.
UBI8 is another one of these generic container images.
And UBI is the Red Hat Universal Base Image.
UBI8 is the one that is based on RHEL 8.
And you might wonder, hey, I'm using a RHEL 10.
Don't I have to use UBI10?
No, not necessarily.
Depends on what you want to do with it.
If you already have UBI8 and you don't
want to pull the UBI10 image as well,
then it's up to you if you want to use UBI8.
So Popman Run UBI8 sleep will run the sleep command
within your UBI8 container image.
Command line options for a specific Popman command
need to be specified before the name of the image.
So all the arguments to Popman Run
need to be behind Popman Run.
We've already talked about it.
Use Popman Run minus D and not Popman Run image name minus D.
Because then it will be interpreted the wrong way.
Now some more common Popman commands.
Popman Search searches the registries for images.
We have already seen it.
And Popman Run allows you to run a container.
Popman Stop stops a currently running container.
And Popman PS shows information about running containers.
And if you expect to see a container
but you don't see it, use Popman PS minus A,
which will show information about containers
that are currently running as well as stopped containers.
We have seen how Popman Inspect can
be used to show container or image details.
And Popman Pull can be separately
used to pull an image from the container.
Popman Exec executes a command in a running container.
And Popman RM removes a container.
In the next demo, I'll show you how all of this is working.
So let me start with a Popman Search UBI.
And there we can see all the different UBI images,
like UBI 10 images.
And do we see UBI in Docker yet?
They are even in Docker.
Now the thing is that Red Hat has removed the official images
from Docker.
So you don't see anything that was created by Red Hat.
Now I would like to use the UBI 10 that we can see here,
registry.redhat.io slash UBI.
registry.redhat.io slash UBI 10.
To make it a little bit easier for me, I'm copying it.
And then I'm going to use Popman Run.
And Popman Run also has a lot, really a lot of options.
And use minus minus help if you want to see all of them.
I don't want to discuss all of them.
But I do want to show you Popman Run minus minus name,
Sleepy.
I don't want to use the automatically generated name.
I want to put the name myself.
Then I'm pasting the image.
And I'm using the command that I want to run, sleep 3600.
Two things.
I'm pasting the image because image names in Container World
often change.
It might happen that if you watch this video course a bit
later, a while after I created it,
that images in the slides suddenly don't work anymore.
Then I would advise use Popman Search and use something
that you see in the result of your Popman Search.
Second thing is this sleep 3600.
What we do here is we replace the default command.
The default command in UBI 10, being a system image,
is where it is going to start a shell.
Here, I'm telling it do not run the shell as PID1,
but run the command sleep 3600 as the default command.
And oh boy, what is happening?
Well, I'm getting an error message.
It's telling me unable to retrieve authentication token
unauthorized.
Now, what is going on?
Well, apparently, in order to use registry.redhat.io,
I need to authenticate.
Well, you remember how to do that.
Popman login for registry.redhat.io.
And then we have a username.
And we have a password.
In this case, I'm going to use my Red Hat credentials
for the simple reason that I have internet access
to the Red Hat service.
But if you listened carefully, then you
should know that on the exam, most likely,
you do not have access to the internet.
So how does this work on the exam?
Well, if they require you to do a Popman login,
somewhere in the exam information,
there must be information about the account
that you are going to use.
So if you're confused, read carefully.
It might be in the question itself.
It might also be in the generic information
that you should have read carefully
before you started the exam.
Good.
I'm logged in.
So I can try again this Popman run command.
And this seems to be more successful.
Well, at least I'm not getting an error message immediately.
So what is happening?
Well, we are looking at the cursor,
and nothing seems to be happening.
Well, it should be obvious what is happening.
Let me open a new window.
And in the new window, let me type Popman PS.
And there we can see that 32 seconds ago,
the Container Sleep 3600 was started.
What does that mean?
Well, that means that we need to wait for a long time
before we get our console back.
I don't want to wait for a long time.
So I'm going to use Popman Stop on Sleepy.
And that will stop the container.
Now, Popman Stop is an interesting command.
It will give the container a default of 10 seconds
to go away.
And if it didn't work within 10 seconds,
then it will give you the message, hey,
I tried sick term.
You know sick term is like a normal kill command.
But that's filled within 10 seconds,
so resorting to sick kill.
That means that you never need to use Popman kill.
You just have to wait for it.
Now, we have an interesting situation here.
When I use Popman PS minus 8,
then we can see the Sleepy container.
Now, Popman Run will run a new container,
but you can also use Popman Start.
And Popman Start allows you to run
an already existing container.
We do have a couple of options to start it as well,
not as many as Popman Run because Popman Start
is really trying to restart a container that
was already started with all the options
that you have used before.
So what does that mean?
Well, that means that if I'm going
to use Popman Start on Sleepy, then
it's going to start the Sleepy container again.
And Popman PS is showing that that worked all right.
Created is set two minutes ago because Popman Start
doesn't create it.
It only starts something that already was created.
And we can see that the status is up since four seconds.
And the nice thing about Popman Start
is that it automatically moves to the background.
Now, I want to stop it again.
So Popman Stop on Sleepy.
Now, I'm using Popman Images.
And look at that.
We have the UBI 10 image.
And now, I'm going to use Popman Run minus D minus
minus name Sleepy.
That's a scenario that is kind of understandable, right?
So you are trying to do it right this time
and restart the container image that failed before.
We do need the image name, of course.
And there we go.
And uh-oh, what do we get here?
Well, here we get a fundamental problem
that many people new to containers like to make.
The problem is that we have a hard-coded name.
And here, I'm using Popman Run, which
creates a new container with a name that already exists.
And that doesn't make sense.
And that is why we get this error message.
Container is already in use by.
And now, we see the container ID.
So if you really would want to do it again,
you need Popman RM Sleepy.
This demonstrates a couple of things.
First, it demonstrates that hard-coded names are not
that convenient.
Secondly, it demonstrates that if your first Popman Run failed,
instead of running it again, particularly
if you want to run it in the background,
you might just use Popman Start instead.
And that's it for now.
Let me talk about troubleshooting a little bit.
So troubleshooting a container is often
troubleshooting the container primary command.
Notice that some containers run to completion.
And there's nothing really to troubleshoot
if you don't see them.
Now, in order to troubleshoot, you
should start by trying to understand what
your container wants to do.
So Popman Inspect allows you to see which command
the container wants to run.
It might also be an option to use Popman Run minus IT
to start the container with an interactive terminal
so that you directly get access to the container.
Or you use Popman Exec minus IT to run
a command, a secondary command, in a container that's
already running so that you can find out what it is doing.
And also convenient, if your container just stops
and you have no clue what is going on, use Popman Logs.
That will show you the logs that were created by the container.
And these logs, well, that is really
the output of the main application of your container.
And that is very valuable for troubleshooting.
Let me show you.
So first, I want to show you Popman PS.
So we have this upbeat Brunel already running.
So I'm going to use Popman Exec minus IT on upbeat Brunel.
And I'm trying to run a bash shell.
It's not always sure that bash is available,
but you will see that immediately, ah, no bash.
Well, then I need to go for SH, the minimal shell.
And look, here we are in the minimal shell in the container.
Now, in this case, it works well, and I can use PS.
But if I try to do the exact same thing on laughing,
whatever, there you can see that when I type PS,
it's telling me command not found.
That also confuses people a lot.
Why is it saying so?
Well, it's saying so because a container is a fancy way
to run an application.
All you need in a container image
is the dependencies that your application requires.
And you should wonder, do I need the PS command
to run my application?
And the answer is probably no.
And that is why some container images don't have PS,
and you will get command not found.
So you can do an LS, but not much more than that.
And let me get out of there.
And this is also why Popman logs is so convenient.
So when I use Popman run minus D MariaDB,
and what is going to happen?
Well, first thing, I didn't use a fully qualified image name.
So it's asking, what do you want to do?
Well, I want to use a docker.io because I
know the registry Red Hat ones have some minor issues that
make it more complicated.
So let me use a docker.io image.
And here it is trying to pull the docker.io image.
And then I'm using Popman PS, and oh boy, I don't see it.
So what do I do next?
Popman PS minus A. And there I can
see that my MariaDB exited with an exit code 1
nine seconds ago.
What does exit code 1 mean?
That means that the main application is filled.
So optimistic Jamison is not that optimistic.
And how are we going to troubleshoot?
Well, Popman logs is convenient here.
If you see exit anything that is not a 0,
that means that your main application has
filtered an error.
And then you want to consult the application output.
And Popman logs is how you do that.
So I'm using Popman logs optimistic Jamison.
And what do we see?
It has an error.
Database is uninitialized and password option is not set.
You need to specify one of the following.
Well, I'm going to do that again in one of the later videos
about containers, but not now.
For now, you know enough about troubleshooting.