{"id":3126,"date":"2021-03-19T13:41:50","date_gmt":"2021-03-19T18:41:50","guid":{"rendered":"https:\/\/microsoftgeek.com\/?p=3126"},"modified":"2021-03-19T13:48:26","modified_gmt":"2021-03-19T18:48:26","slug":"how-to-install-docker-on-centos-8","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=3126","title":{"rendered":"How to Install Docker on CentOS 8"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What is Docker?<\/h2>\n\n\n\n<p>Before we begin, let&#8217;s describe what Docker is. Docker is a set of virtualization tools that allows us to create, test, and deploy containerized applications quickly and easily on a\u00a0dedicated server. It has become very popular and used almost everywhere in our daily lives. Thanks to containerization, we can quickly launch applications on different\u00a0private cloud host platforms\u00a0utilizing small bundles which contain all the needed packages, libraries and configuration file to run an application. These docker packages communicate via established network channels.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/lwgatsby\/f_auto\/www\/uploads\/2020\/03\/black-concrete-biulding-51325.jpg\" alt=\"Docker Silhouette\" class=\"wp-image-28034\"\/><figcaption>Docker Silhouette<\/figcaption><\/figure>\n\n\n\n<p>Docker has two main versions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Docker CE (Community Edition)<\/li><li>Docker EE (Enterprise Edition)<\/li><\/ul>\n\n\n\n<p>We will not be discussing many of the new features of CentOS 8 that function with Docker, as RedHat has decided not to provide official support for Docker. But, Redhat does offer several built-in tools for\u00a0creating and managing container images within a server cluster, more specifically Buildah and Podman. These tools are docker compatible, but they require a server\/client architecture.\u00a0Many prefer to use Docker containerization, and in this tutorial, we want to demonstrate how to install Docker on CentOS using an external repository.\u00a0So let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Docker CE<\/h2>\n\n\n\n<p>To get started, we should remove all existing docker applications (that might currently be installed) in order to make sure we are using a clean installation. You may not have some of these components installed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine\n\nModular dependency problems:\nProblem 1: conflicting requests\n- nothing provides module(perl:5.26) needed by module perl-DBD-SQLite:1.58:8010020191114033549:073fa5fe-0.x86_64\nProblem 2: conflicting requests\n- nothing provides module(perl:5.26) needed by module perl-DBI:1.641:8010020191113222731:16b3ab4d-0.x86_64\nNo match for argument: docker\nNo match for argument: docker-client\nNo match for argument: docker-client-latest\nNo match for argument: docker-common\nNo match for argument: docker-latest\nNo match for argument: docker-latest-logrotate\nNo match for argument: docker-logrotate\nNo match for argument: docker-engine\nNo packages marked for removal.\nDependencies resolved.\nNothing to do.\nComplete!\n[root@host ~]#<\/pre>\n\n\n\n<p>Next, we want to add an external repository that will help us obtain the Docker software.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# dnf config-manager --add-repo=https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\nAdding repo from: https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\n[root@host ~]#<\/pre>\n\n\n\n<p>Now, let&#8217;s check what versions of docker we have in the repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# dnf list docker-ce\nCentOS-8 - AppStream 7.7 kB\/s | 4.3 kB 00:00\nCentOS-8 - Base 32 kB\/s | 3.8 kB 00:00\nCentOS-8 - Extras 4.0 kB\/s | 1.5 kB 00:00\nDocker CE Stable - x86_64 55 kB\/s | 22 kB 00:00\nAvailable Packages\ndocker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable\n[root@host ~]#<\/pre>\n\n\n\n<p>Unfortunately, the latest version of Docker is not always in the available in all repositories. To resolve this and obtain the most suitable, and stable release version, we will use the &#8220;<em>nobest<\/em>&#8221; flag. We will use this option because it will allow CentOS 8 to install the most appropriate version for our needs. If we need to\u00a0install the latest version of docker, this option would not the right choice for us. We will, however, continue to install the version that best matches our CentOS server version.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify Docker Version<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/lwgatsby\/f_auto\/www\/uploads\/2020\/03\/containers-163726.jpg\" alt=\"containers-163726\" class=\"wp-image-28037\"\/><\/figure>\n\n\n\n<p>Now, we can double-check if the installation was successful by using the version command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# docker -v\nDocker version 19.03.7, build 7141c199a2\n[root@host ~]#<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Launch Docker<\/h2>\n\n\n\n<p>Next, lets start the Docker daemon with the systemctl command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# systemctl enable --now docker\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/docker.service \u2192 \/usr\/lib\/systemd\/system\/docker.service.\n[root@host ~]#<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Confirm Install<\/h2>\n\n\n\n<p>Next, we can finally confirm that\u00a0Docker\u00a0has started and is working with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# systemctl status docker\n\u25cf docker.service - Docker Application Container Engine\nLoaded: loaded (\/usr\/lib\/systemd\/system\/docker.service; enabled; vendor pres>\nActive: active (running) since Thu 2020-03-05 06:30:02 EST; 2min 30s ago\nDocs: https:\/\/docs.docker.com\nMain PID: 2798 (dockerd)\nTasks: 21\nMemory: 140.7M\nCGroup: \/system.slice\/docker.service\n\u251c\u25002798 \/usr\/bin\/dockerd -H fd:\/\/\n\u2514\u25002805 containerd --config \/var\/run\/docker\/containerd\/containerd.tom>\n\nMar 05 06:29:52 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:29:52.>\nMar 05 06:29:52 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:29:52.>\nMar 05 06:29:52 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:29:52.>\nMar 05 06:29:52 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:29:52.>\nMar 05 06:29:57 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:29:57.>\nMar 05 06:29:59 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:29:58.>\nMar 05 06:30:01 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:30:01.>\nMar 05 06:30:01 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:30:01.>\nMar 05 06:30:02 localhost.localdomain dockerd[2798]: time=\"2020-03-05T06:30:02.>\nMar 05 06:30:02 localhost.localdomain systemd[1]: Started Docker Application Co>\n\n[root@host ~]#<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Add User<\/h2>\n\n\n\n<p>The next step is to add a user to the Docker user group employing the &#8220;<em>usermod<\/em>&#8221; command.<\/p>\n\n\n\n<p>Additionally, when we use the &#8220;<em>id root<\/em>&#8221; command after adding the user, this will show us whether the user is now included within the docker group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# usermod -aG docker root\n[root@host ~]# id root\nuid=0(root) gid=0(root) groups=0(root),976(docker)\n[root@host ~]#<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Disable Firewall<\/h2>\n\n\n\n<p>Next, we are going to temporarily turn off firewalld to allow Docker containers to work internally.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# systemctl disable firewalld\nRemoved \/etc\/systemd\/system\/multi-user.target.wants\/firewalld.service.\nRemoved \/etc\/systemd\/system\/dbus-org.fedoraproject.FirewallD1.service.\n[root@host ~]#<\/pre>\n\n\n\n<p>Caution:We recommend you perform a reboot after this step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Deploy Test App<\/h2>\n\n\n\n<p>In our last step, we will install a test application called &#8220;<em>hello-world<\/em>&#8221; to ensure our installation is working as expected. We will deploy the program using the following &#8220;<em>docker<\/em>&#8221; command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# docker run hello-world\nUnable to find image 'hello-world:latest' locally\nlatest: Pulling from library\/hello-world\n1b930d010525: Pull complete\nDigest: sha256:fc6a51919cfeb2e6763f62b6d9e8815acbf7cd2e476ea353743570610737b752\nStatus: Downloaded newer image for hello-world:latest\n\nHello from Docker!\nThis message shows that your installation appears to be working correctly.\n\nTo generate this message, Docker took the following steps:\n1. The Docker client contacted the Docker daemon.\n2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\n(amd64)\n3. The Docker daemon created a new container from that image which runs the\nexecutable that produces the output you are currently reading.\n4. The Docker daemon streamed that output to the Docker client, which sent it\nto your terminal.\n\nTo try something more ambitious, you can run an Ubuntu container with:\n$ docker run -it ubuntu bash\n\nShare images, automate workflows, and more with a free Docker ID:\nhttps:\/\/hub.docker.com\/\n\nFor more examples and ideas, visit:\nhttps:\/\/docs.docker.com\/get-started\/\n\n[root@host ~]#<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Install Docker Compose<\/h2>\n\n\n\n<p>As an additional step, we will install Docker Compose. Docker Compose is a very useful application which allows us to connect several containers together using minimal commands, or when we need to run several containers together which depend on each other.<\/p>\n\n\n\n<p>We will start the installation using the following &#8220;<em>dnf<\/em>&#8220;command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# dnf install curl -y\nLast metadata expiration check: 0:42:26 ago on Thu 05 Mar 2020 06:08:47 AM EST.\nPackage curl-7.61.1-11.el8.x86_64 is already installed.\nDependencies resolved.\nNothing to do.\nComplete!\n[root@host ~]#<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Obtaining the Docker Compose Package<\/h2>\n\n\n\n<p>We will obtain the Docker Compose package from GitHub.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/1.25.0\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose\n% Total % Received % Xferd Average Speed Time Time Time Current\nDload Upload Total Spent Left Speed\n100 617 100 617 0 0 1672 0 --:--:-- --:--:-- --:--:-- 1672\n100 16.2M 100 16.2M 0 0 3914k 0 0:00:04 0:00:04 --:--:-- 4990k\n[root@host ~]<\/pre>\n\n\n\n<p>Next, we will adjust the permissions for the file using the &#8220;<em>chmod<\/em>&#8221; command to make it executable.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# chmod +x \/usr\/local\/bin\/docker-compose\n[root@host ~]#<\/pre>\n\n\n\n<p>To check which version we have installed, run the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host ~]# docker-compose -v\ndocker-compose version 1.25.0, build 0a186604\n[root@host ~]#<\/pre>\n\n\n\n<p>Conclusion<br>In this article, we have discussed the basic concepts of Docker and how to install it in CentOS 8. Additionally, we installed Docker compose. Docker is one of the most useful tools when a modern containerization platform is needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Docker? Before we begin, let&#8217;s describe what Docker is. Docker is a set of virtualization tools that allows us to create, test, and deploy containerized applications quickly and easily on a\u00a0dedicated server. It has become very popular and used almost everywhere in our daily lives. Thanks to containerization, we can quickly launch applications [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78,77,82,13],"tags":[],"class_list":["post-3126","post","type-post","status-publish","format-standard","hentry","category-containers","category-devops","category-docker","category-linux"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3126"}],"version-history":[{"count":4,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3126\/revisions"}],"predecessor-version":[{"id":3130,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3126\/revisions\/3130"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}