1 00:00:06,519 --> 00:00:09,130 To run containers, you use either Docker or Podman. 2 00:00:10,169 --> 00:00:14,890 Docker started the container revolution in 2014, and it's still commonly used. 3 00:00:16,030 --> 00:00:20,170 Podman is the newer solution that was first introduced in Red Hat Enterprise Linux in 2018. 4 00:00:22,210 --> 00:00:28,530 It's the default container managed in Red Hat family Linux, but it is also available on other Linux distributions. 5 00:00:29,449 --> 00:00:35,530 The Podman command line interface was developed to be completely compatible with the Docker command line interface. 6 00:00:36,590 --> 00:00:43,000 As a result, for all Docker commands in this lesson, you might as well replace the command Docker with Podman. 7 00:00:43,539 --> 00:00:49,869 Or if you want to, now that you know about shell aliases, just create an alias Docker is Podman or Podman is Docker. 8 00:00:50,869 --> 00:00:56,786 Now, in order to work with it, you need to install it on Red Hat family distributions. Podman is 9 00:00:56,786 --> 00:01:02,703 available by default, and Docker is no longer supported on Red Hat family distributions. So don't try it. It 10 00:01:02,703 --> 00:01:08,620 won't work, and if it will work, it will break very first time you update your distribution. 11 00:01:09,659 --> 00:01:16,265 If you want to install Docker on non Red Hat distributions, you use sudo apt install Docker IO and 12 00:01:16,265 --> 00:01:22,870 to install podman on non Red Hat distributions, you use sudo apt install podman and on Red Hat itself, 13 00:01:22,870 --> 00:01:29,475 you you don't have to do anything to run a container. You need access to registries and the Docker 14 00:01:29,474 --> 00:01:36,079 Hub, which is found@hub.docker.com is the biggest registry, and it can be used by Docker or podman. 15 00:01:37,120 --> 00:01:43,900 Even if anonymous registry access is possible, you may have to create an account and login to get access to all the 16 00:01:43,900 --> 00:01:50,680 features that are offered by the registry, and you can use the Docker login command to login. So dockerlogin docker.com allows you 17 00:01:50,679 --> 00:01:57,459 to login to the Docker registry and replace docker.com with the name of any registry that you would like to log into. 18 00:01:58,359 --> 00:02:01,010 Now I'm about to show you how to run a container. 19 00:02:01,689 --> 00:02:04,159 The main command to run a container is Docker Run. 20 00:02:05,040 --> 00:02:10,773 When that happens, the container image is fetched or pulled, as we call it in containerized environments. 21 00:02:10,773 --> 00:02:16,506 First, if short container names are used, the image is often fetched from the Docker Registry, and 22 00:02:16,506 --> 00:02:22,240 you can use Docker Search or the Registry web interface to search for specific images. 23 00:02:23,069 --> 00:02:28,729 And when you are using Docker Run, don't forget to add the D option to run a container in the background. 24 00:02:29,770 --> 00:02:33,980 Alternatively, if your container image offers an interactive terminal like a shell, 25 00:02:33,980 --> 00:02:38,189 you can use Docker run it to open that interactive terminal. 26 00:02:38,930 --> 00:02:44,743 Now, if you want to specify an image from another registry, you can Use the 27 00:02:44,743 --> 00:02:50,557 fully qualified container name or fqcn. So instead of using Docker, run D. Nginx, which 28 00:02:50,557 --> 00:02:56,371 would definitely work in a Docker environment, you might want to use Docker run d 29 00:02:56,372 --> 00:03:02,186 Docker IO library nginx that is pulling the same container image. But particularly in Podman 30 00:03:02,186 --> 00:03:08,000 environments where the Docker registry is not hard coded, this is preferred. 31 00:03:08,460 --> 00:03:12,159 Now, the FQCN can normally be obtained from the container registry. 32 00:03:12,689 --> 00:03:19,229 And to check running containers, use Docker ps and to check on downloaded images, use Docker images. 33 00:03:19,889 --> 00:03:22,189 Let me show you how to get started with containers. 34 00:03:23,530 --> 00:03:28,979 So for this demo I'm going to use Ubuntu for the simple reason that Ubuntu has the option to install Docker. 35 00:03:29,500 --> 00:03:35,180 And installing Docker is more complex than getting started with Podman or Red Hat, because Podman or Red Hat is just there. 36 00:03:35,840 --> 00:03:39,534 And don't forget, if you are in Red Hat, you can just replace 37 00:03:39,534 --> 00:03:43,229 the Docker command with the Podman command and it will just work. 38 00:03:45,169 --> 00:03:50,496 So let me start by installing it using Sudo apt installation Docker IO and that 39 00:03:50,496 --> 00:03:55,823 is giving me an overview of everything that it wants to install. So do I 40 00:03:55,823 --> 00:04:01,150 want to continue? Yes, I want to continue, because otherwise I can't use it. 41 00:04:03,770 --> 00:04:06,990 Now that I have installed Docker IO, There is one thing. 42 00:04:07,810 --> 00:04:11,849 If a user wants to run a Docker container, the user needs to be a member of the Docker group. 43 00:04:12,379 --> 00:04:13,439 Otherwise this happens. 44 00:04:14,159 --> 00:04:17,920 Let me show you Docker run D nginx that's giving 45 00:04:17,920 --> 00:04:21,680 me a permission denied while talking to the Docker daemon. 46 00:04:22,259 --> 00:04:27,704 So I am going to use UserMod AG Docker for user student to make 47 00:04:27,704 --> 00:04:33,149 the user student member of the group Docker with sudo privileges of course. 48 00:04:34,089 --> 00:04:38,174 And then you need to log out and log in again. Or 49 00:04:38,174 --> 00:04:42,259 the little trick, use newgrp docker to start using that group immediately. 50 00:04:42,899 --> 00:04:47,769 And then you can use Docker run D. Nginx again and it is working. 51 00:04:48,740 --> 00:04:49,490 So what do we see? 52 00:04:50,379 --> 00:04:55,393 Well, we see that it is loading the nginx latest image. In a containerized world, you 53 00:04:55,393 --> 00:05:00,406 will always check for the latest image that is available and pull that if there is 54 00:05:00,406 --> 00:05:05,420 a newer image available or if to start with, the image was not available at all. 55 00:05:06,220 --> 00:05:11,240 For efficiency purposes, container images are often layered. So what you see here, all 56 00:05:11,240 --> 00:05:16,259 these pull completes is about pulling all the different layers of the container image. 57 00:05:17,180 --> 00:05:21,800 And next I can use Docker PS and Docker PS is showing that the container is running. 58 00:05:22,699 --> 00:05:26,730 So the container has a container id. Here we can see the name of the image. 59 00:05:27,529 --> 00:05:32,639 You can see that it is listening on port 80 and it even has a name condescending Britain. 60 00:05:33,459 --> 00:05:39,444 And that is indicating that the container is running. All right, now you can also use 61 00:05:39,444 --> 00:05:45,430 Docker images, and Docker Images is showing the image that has been pulled with the container. 62 00:05:46,149 --> 00:05:49,995 Now, there is one more thing that I would like to show you, and that 63 00:05:49,995 --> 00:05:53,840 is the Docker registry, because here I'm using nginx and that is all pretty cool. 64 00:05:54,959 --> 00:05:58,829 But what if you don't know exactly what to do? 65 00:05:59,370 --> 00:06:05,300 Well, then you go to hub.docker.com and that is the Docker Hub. 66 00:06:08,920 --> 00:06:13,644 Now, in this Docker Hub, you have the search bar. And if you look for the 67 00:06:13,644 --> 00:06:18,370 search bar, then you can look for what, whatever you want to run, like MariaDB. 68 00:06:18,910 --> 00:06:23,666 And look here we get the MariaDB image. So search for your application. You 69 00:06:23,666 --> 00:06:28,423 are likely to find it on the Docker Hub. Even if you are a 70 00:06:28,423 --> 00:06:33,180 Podman user, Docker Hub is still a very valuable resource for finding container images. 71 00:06:34,240 --> 00:06:37,960 So if you scroll down on your container image, you get a lot 72 00:06:37,960 --> 00:06:41,680 of usage information that is explaining how you can use this container image. 73 00:06:42,430 --> 00:06:48,860 So this Docker Hub is really a valuable place to start looking for container images that you want to use.