To run containers, you use either Docker or Podman.
Docker started the container revolution in 2014, and it's still commonly used.
Podman is the newer solution that was first introduced in Red Hat Enterprise Linux in 2018.
It's the default container managed in Red Hat family Linux, but it is also available on other Linux distributions.
The Podman command line interface was developed to be completely compatible with the Docker command line interface.
As a result, for all Docker commands in this lesson, you might as well replace the command Docker with Podman.
Or if you want to, now that you know about shell aliases, just create an alias Docker is Podman or Podman is Docker.
Now, in order to work with it, you need to install it on Red Hat family distributions. Podman is
available by default, and Docker is no longer supported on Red Hat family distributions. So don't try it. It
won't work, and if it will work, it will break very first time you update your distribution.
If you want to install Docker on non Red Hat distributions, you use sudo apt install Docker IO and
to install podman on non Red Hat distributions, you use sudo apt install podman and on Red Hat itself,
you you don't have to do anything to run a container. You need access to registries and the Docker
Hub, which is found@hub.docker.com is the biggest registry, and it can be used by Docker or podman.
Even if anonymous registry access is possible, you may have to create an account and login to get access to all the
features that are offered by the registry, and you can use the Docker login command to login. So dockerlogin docker.com allows you
to login to the Docker registry and replace docker.com with the name of any registry that you would like to log into.
Now I'm about to show you how to run a container.
The main command to run a container is Docker Run.
When that happens, the container image is fetched or pulled, as we call it in containerized environments.
First, if short container names are used, the image is often fetched from the Docker Registry, and
you can use Docker Search or the Registry web interface to search for specific images.
And when you are using Docker Run, don't forget to add the D option to run a container in the background.
Alternatively, if your container image offers an interactive terminal like a shell,
you can use Docker run it to open that interactive terminal.
Now, if you want to specify an image from another registry, you can Use the
fully qualified container name or fqcn. So instead of using Docker, run D. Nginx, which
would definitely work in a Docker environment, you might want to use Docker run d
Docker IO library nginx that is pulling the same container image. But particularly in Podman
environments where the Docker registry is not hard coded, this is preferred.
Now, the FQCN can normally be obtained from the container registry.
And to check running containers, use Docker ps and to check on downloaded images, use Docker images.
Let me show you how to get started with containers.
So for this demo I'm going to use Ubuntu for the simple reason that Ubuntu has the option to install Docker.
And installing Docker is more complex than getting started with Podman or Red Hat, because Podman or Red Hat is just there.
And don't forget, if you are in Red Hat, you can just replace
the Docker command with the Podman command and it will just work.
So let me start by installing it using Sudo apt installation Docker IO and that
is giving me an overview of everything that it wants to install. So do I
want to continue? Yes, I want to continue, because otherwise I can't use it.
Now that I have installed Docker IO, There is one thing.
If a user wants to run a Docker container, the user needs to be a member of the Docker group.
Otherwise this happens.
Let me show you Docker run D nginx that's giving
me a permission denied while talking to the Docker daemon.
So I am going to use UserMod AG Docker for user student to make
the user student member of the group Docker with sudo privileges of course.
And then you need to log out and log in again. Or
the little trick, use newgrp docker to start using that group immediately.
And then you can use Docker run D. Nginx again and it is working.
So what do we see?
Well, we see that it is loading the nginx latest image. In a containerized world, you
will always check for the latest image that is available and pull that if there is
a newer image available or if to start with, the image was not available at all.
For efficiency purposes, container images are often layered. So what you see here, all
these pull completes is about pulling all the different layers of the container image.
And next I can use Docker PS and Docker PS is showing that the container is running.
So the container has a container id. Here we can see the name of the image.
You can see that it is listening on port 80 and it even has a name condescending Britain.
And that is indicating that the container is running. All right, now you can also use
Docker images, and Docker Images is showing the image that has been pulled with the container.
Now, there is one more thing that I would like to show you, and that
is the Docker registry, because here I'm using nginx and that is all pretty cool.
But what if you don't know exactly what to do?
Well, then you go to hub.docker.com and that is the Docker Hub.
Now, in this Docker Hub, you have the search bar. And if you look for the
search bar, then you can look for what, whatever you want to run, like MariaDB.
And look here we get the MariaDB image. So search for your application. You
are likely to find it on the Docker Hub. Even if you are a
Podman user, Docker Hub is still a very valuable resource for finding container images.
So if you scroll down on your container image, you get a lot
of usage information that is explaining how you can use this container image.
So this Docker Hub is really a valuable place to start looking for container images that you want to use.