{"id":5619,"date":"2020-04-29T19:53:12","date_gmt":"2020-04-29T16:53:12","guid":{"rendered":"https:\/\/kifarunix.com\/?p=5619"},"modified":"2024-03-14T20:05:11","modified_gmt":"2024-03-14T17:05:11","slug":"install-docker-ce-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-docker-ce-on-ubuntu-20-04\/","title":{"rendered":"Install Docker CE on Ubuntu 20.04"},"content":{"rendered":"\n<p>In this tutorial, we are going to learn how to install Docker CE on Ubuntu 20.04. <a href=\"https:\/\/docs.docker.com\/get-started\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker<\/a> is a platform that enables developers and system administrators to <strong>build, run, and share<\/strong>&nbsp;applications in <a href=\"https:\/\/www.docker.com\/resources\/what-container\/\" target=\"_blank\" rel=\"noreferrer noopener\">containers<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-docker-ce-on-ubuntu-20-04\">Installing Docker CE on Ubuntu 20.04<\/a><ul><li><a href=\"#installing-docker-ce-from-docker-repositories\">Installing Docker CE from Docker Repositories<\/a><\/li><li><a href=\"#installing-docker-ce-using-deb-binary-package\">Installing Docker CE using DEB Binary Package<\/a><\/li><li><a href=\"#checking-installed-docker-version\">Checking Installed Docker Version<\/a><\/li><li><a href=\"#starting-docker-service\">Starting Docker Service<\/a><\/li><li><a href=\"#running-docker-as-a-non-root-user\">Running Docker as a non-root user<\/a><\/li><li><a href=\"#verifying-docker-ce-installation\">Verifying Docker CE installation<\/a><\/li><li><a href=\"#reference\">Reference<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-docker-ce-on-ubuntu-20-04\">Installing Docker CE on Ubuntu 20.04<\/h2>\n\n\n\n<p>The exits two editions of docker available. <code>Docker CE<\/code> and <code>Docker EE<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Docker CE  (Community Edition) is the open-source, community supported version of Docker and is available for free.<\/li>\n\n\n\n<li>Docker EE (Enterprise Edition) is a commercial\/premium version of Docker CE and is support by Docker Inc.<\/li>\n<\/ul>\n\n\n\n<p>There are different methods in which you can install Docker CE;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#docker-repos\">Installing Docker CE from Docker Repositories<\/a><\/li>\n\n\n\n<li><a href=\"#deb-binary\">Installing Docker CE using the DEB binary package<\/a><\/li>\n\n\n\n<li>Installing Docker CE using Docker Installation Script (<strong>Beyond the scope of this tutorial<\/strong>).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-docker-ce-from-docker-repositories\">Installing Docker CE from Docker Repositories<\/h3>\n\n\n\n<p>To install Docker CE from Docker, you first need to install some required packages by executing the command below. Some of the package may already be installed though;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common<\/pre>\n\n\n\n<p>Next, install Docker repository GPG signing key.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | \\\nsudo gpg --dearmor &gt; \/etc\/apt\/trusted.gpg.d\/docker.gpg<\/pre>\n\n\n\n<p>Install Docker repository on Ubuntu 20.04.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo \"deb [arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -sc) stable\" \\\n&gt; \/etc\/apt\/sources.list.d\/docker-ce.list<\/pre>\n\n\n\n<p>After that, update package cache.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt update<\/pre>\n\n\n\n<p>Install Docker CE and other tools including <code>containerd.io<\/code>, An open and reliable container runtime.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install docker-ce docker-ce-cli containerd.io<\/pre>\n\n\n\n<p>Note that, even if you install just docker-ce package, other tools like <code>docker-ce-cli<\/code> and <code>containerd.io<\/code> will be installed along with it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install docker-ce<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nReading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nThe following additional packages will be installed:\n  aufs-tools cgroupfs-mount containerd.io docker-ce-cli pigz\nThe following NEW packages will be installed:\n  aufs-tools cgroupfs-mount <strong>containerd.io docker-ce docker-ce-cli<\/strong> pigz\n0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 111 MB of archives.\nAfter this operation, 401 MB of additional disk space will be used.\nDo you want to continue? [Y\/n]\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-docker-ce-using-deb-binary-package\">Installing Docker CE using DEB Binary Package<\/h3>\n\n\n\n<p>If you want to go the manual way, you can simply download Docker CE DEB binary package for your specific system version from <a href=\"https:\/\/download.docker.com\/linux\/ubuntu\/dists\/focal\/pool\/stable\/amd64\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/download.docker.com\/linux\/ubuntu\/dists\/<\/a>.<\/p>\n\n\n\n<p>For example, in this case to download the DEB binary packages for Focal Fossa (Ubuntu 20.04), navigate to <a rel=\"noreferrer noopener\" href=\"https:\/\/download.docker.com\/linux\/ubuntu\/dists\/focal\/pool\/stable\/amd64\/\" target=\"_blank\">https:\/\/download.docker.com\/linux\/ubuntu\/dists\/focal\/pool\/stable\/amd64\/<\/a> and grab the <strong><code>.deb<\/code><\/strong> files.<\/p>\n\n\n\n<p>To download <code>docker-ce<\/code>, <code>docker-ce-cli<\/code> and <code>containerd.io<\/code>, you would simply pull them as follows;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget https:\/\/download.docker.com\/linux\/ubuntu\/dists\/focal\/pool\/stable\/amd64\/docker-ce_24.0.2-1~ubuntu.20.04~focal_amd64.deb<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">wget https:\/\/download.docker.com\/linux\/ubuntu\/dists\/focal\/pool\/stable\/amd64\/docker-ce-cli_24.0.2-1~ubuntu.20.04~focal_amd64.deb<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">wget https:\/\/download.docker.com\/linux\/ubuntu\/dists\/focal\/pool\/stable\/amd64\/containerd.io_1.6.21-1_amd64.deb<\/pre>\n\n\n\n<p>You can then install them using the <code>apt<\/code> or <code>dpkg<\/code> package manager. Be sure to install <code>docker-ce-cli<\/code> and <code>containerd.io<\/code> before <code>docker-ce<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install .\/docker-ce-cli_24.0.2-1~ubuntu.20.04~focal_amd64.deb<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install .\/containerd.io_1.6.21-1_amd64.deb<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install .\/docker-ce_24.0.2-1~ubuntu.20.04~focal_amd64.deb<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"checking-installed-docker-version\">Checking Installed Docker Version<\/h3>\n\n\n\n<p>To check the version of installed Docker, simply run the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Docker version 24.0.2, build cb74dfc<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"starting-docker-service\">Starting Docker Service<\/h3>\n\n\n\n<p>To start and enable Docker and Containerd service to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable --now docker containerd<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"running-docker-as-a-non-root-user\">Running Docker as a non-root user<\/h3>\n\n\n\n<p>If you run Docker as standard system user, you may get such an error;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">docker run hello-world<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">docker: Got permission denied while trying to connect to the Docker daemon socket at unix:\/\/\/var\/run\/docker.sock: <strong>...<\/strong>\n\/var\/run\/docker.sock: connect: permission denied.\nSee 'docker run --help'.<\/pre>\n\n\n\n<p>Therefore, if you need to run docker as non-root user, simply add the user you want to run docker as to docker group or simply, grant the user sudo rights. For example to add current user to <code>docker<\/code> group;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo usermod -aG docker $USER<\/pre>\n\n\n\n<p><strong>Once you have added the user to the Docker group, log out and login again to have the user group membership re-evaluated.<\/strong><\/p>\n\n\n\n<p>You can then run docker as the standard user.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"verifying-docker-ce-installation\">Verifying Docker CE installation<\/h3>\n\n\n\n<p>To verify that Docker CE is running well, you can try running the <code>hello-world<\/code>&nbsp;container image.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">docker run hello-world<\/pre>\n\n\n\n<p><strong>NOTE:<\/strong> If you still get the same <code><strong>permission denied<\/strong><\/code> error after adding user to docker group, logout and login again and you should be able to run docker as a standard user.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\nUnable to find image 'hello-world:latest' locally\nlatest: Pulling from library\/hello-world\n0e03bdcc26d7: Pull complete \nDigest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76\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:\n 1. The Docker client contacted the Docker daemon.\n 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\n    (amd64)\n 3. The Docker daemon created a new container from that image which runs the\n    executable that produces the output you are currently reading.\n 4. The Docker daemon streamed that output to the Docker client, which sent it\n    to 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:\n https:\/\/hub.docker.com\/\n\nFor more examples and ideas, visit:\n https:\/\/docs.docker.com\/get-started\/\n<\/code><\/pre>\n\n\n\n<p>To list running containers;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">docker ps -a<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES\n4083300e3660        hello-world         \"\/hello\"            5 minutes ago       Exited (0) 5 minutes ago                       recursing_tereshkova<\/code><\/pre>\n\n\n\n<p>There you go. You have successfully installed Docker CE on Ubuntu 20.04. You can now explore Docker further.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"reference\">Reference<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.docker.com\/engine\/install\/ubuntu\/#install-using-the-convenience-script\" target=\"_blank\">Docker Engine Installation on Ubuntu<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/monitor-docker-swarm-node-metrics-using-grafana\/\" target=\"_blank\" rel=\"noreferrer noopener\">Monitor Docker Swarm Node Metrics using Grafana<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/monitor-docker-containers-metrics-using-grafana\/\" target=\"_blank\" rel=\"noreferrer noopener\">Monitor Docker Containers Metrics using Grafana<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to learn how to install Docker CE on Ubuntu 20.04. Docker is a platform that enables developers and system<\/p>\n","protected":false},"author":1,"featured_media":9718,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[1076,1077,121],"tags":[1079,1510,1509,1514,4659,1511,1512,1513,1200],"class_list":["post-5619","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-containers","category-docker","category-howtos","tag-docker","tag-docker-ce-ubuntu-20-04","tag-docker-ubuntu-20-04","tag-docker-ce","tag-install-docker-ce-ubuntu-20-04-2","tag-install-docker-ubuntu-20-04","tag-install-docker-ce-ubuntu-20-04","tag-run-docker-as-non-root-user","tag-ubuntu-20-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/5619"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=5619"}],"version-history":[{"count":13,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/5619\/revisions"}],"predecessor-version":[{"id":21351,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/5619\/revisions\/21351"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9718"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=5619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=5619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=5619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}