So, our next task is managing containers. On server 2, create a container with the name
mydb that runs the MariaDB database that uses Shisha using a MariaDB 10.11 image. The container
should meet the following requirements. First, the host directory home.shisha.mydb is mounted
on the container directory varlib-mysql. The container is accessible on host port 3306.
You do not have to create any database in it, but you do need to set the database root
user password to password. Let me show you the solution. So, first, let me use dnf install
–y popman. We're on a minimal system, and on a minimal system, popman is not installed
by default. Okay, so now I can start a shell that uses Shisha. And as this user, I'm going
to start popman search MariaDB-10.11. After all, we need the fully qualified container
image name, which is registry.redhat.io slash rel 10 slash MariaDB 10.11. So, it's on registry.redhat.io
and for that reason, I'm going to use popman login to registry.redhat.io.
If this is happening on the real exam, the real exam is not connected to the internet.
So, it's unlikely that you are going to use your normal internet credentials, but read
the documentation in the real exam for information on which credentials to use.
And as you can see, I already was logged in. Well, that makes it easier.
So, next, I need mkdir mydb to create a directory. And this directory is going to be bank mounted
in the container. And in order to do so, as the container is going to run as user ID 27,
which is the case for MariaDB, as we have seen before, I need popman unshared shown
27 colon 27 on mydb to ensure that the container has access to the mydb directory.
So, what do we see? Well, ls minus ld on mydb is showing that we have this dynamically generated
user ID. And for now, that is okay. And we are going to use it. So, now that I have set the
ownership, we can double check it. By the way, popman unshared ls minus ld on mydb is showing
the ownership is correctly set to 27, 27. And that means that now I can run popman run minus d
a registry.redhat.io slash rel 10 slash MariaDB dash 10 11. What else do we need? Well,
we need to port mapping. So, minus p 3306 to 3306. And we need the environment variable.
So, minus e MariaDB root password
is password. And we also need the bind mount, which is minus v slash home slash
chicha slash mydb to var lib mysql colon z to take care of SE Linux. And oh boy,
am I doing something wrong? I definitely do because directly after the minus d, I have the
fully qualified container image name. That doesn't work. The fully qualified container image name
needs to be at the end of the line. So, registry.redhat.io slash rel 10 slash MariaDB dash
10 11. That should be doing it. So, now let's verify using popman ps. And oh no,
nothing is going on. Popman ps minus a is showing what? It's showing that it exited with one. So,
we need some troubleshooting. Popman logs on c5e. And what do we see? Ah, we see that the variable
is mysql root password instead of MariaDB root password. Well, that means that we were almost
there. There is another thing that we forgot, by the way, and that is the name, minus n mydb. Well,
that makes it easy to fix it. I can just use the up arrow key. And we change MariaDB to mysql
root password. And now we need minus n mydb. So, I need to change the MariaDB root password
to mysql root password. And I need to specify the name, minus minus name mydb. So, let's try it
again and do a popman ps. And here we can see that popman ps is actually, it's running. And
as a double check, ls minus z on mydb is showing that some files have been created in container
file t, as the SELinux context label is set. So, we are good, and we are ready to continue.