{"id":6211,"date":"2021-10-27T21:57:41","date_gmt":"2021-10-27T21:57:41","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=6211"},"modified":"2021-10-27T21:57:41","modified_gmt":"2021-10-27T21:57:41","slug":"install-docker-on-debian","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2021\/10\/27\/install-docker-on-debian\/","title":{"rendered":"Install Docker on Debian"},"content":{"rendered":"<p>Set up the repository<br \/>\nUpdate the apt package index and install packages to allow apt to use a repository over HTTPS:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo apt-get update\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo apt-get install ca-certificates curl gnupg lsb-release\n<\/pre>\n<p>Add Docker\u2019s official GPG key:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg\n<\/pre>\n<p>Use the following command to set up the stable repository.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\necho \\\n &quot;deb &#x5B;arch=$(dpkg --print-architecture) signed-by=\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/debian \\\n  $(lsb_release -cs) stable&quot; | sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null\n<\/pre>\n<p>Install Docker Engine<\/p>\n<p>Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo apt-get update\n$ sudo apt-get install docker-ce docker-ce-cli containerd.io\n<\/pre>\n<p>Verify that Docker Engine is installed correctly by running the hello-world image.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo docker run hello-world\n<\/pre>\n<p>Configure Docker to start on boot<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo systemctl enable docker.service\n$ sudo systemctl enable containerd.service\n<\/pre>\n<p>Manage Docker as a non-root user<br \/>\nCreate the docker group.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo groupadd docker\n<\/pre>\n<p>Add your user to the docker group.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo usermod -aG docker $USER\n<\/pre>\n<p>Log out and log back in so that your group membership is re-evaluated. If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect. On a desktop Linux environment such as X Windows, log out of your session completely and then log back in.<\/p>\n<p>On Linux, you can also run the following command to activate the changes to groups:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnewgrp docker \n<\/pre>\n<p>Verify that you can run docker commands without sudo.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ docker run hello-world\n<\/pre>\n<p>This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.<\/p>\n<p>Configuring remote access with systemd unit file<\/p>\n<p>Use the command sudo systemctl edit docker.service to open an override file for docker.service in a text editor. Add or modify the following lines, substituting your own values.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;Service]\nExecStart=\nExecStart=\/usr\/bin\/dockerd -H fd:\/\/ -H tcp:\/\/127.0.0.1:2375\n<\/pre>\n<p>Save the file. Reload the systemctl configuration.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n sudo systemctl daemon-reload\n<\/pre>\n<p>Restart Docker.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n sudo systemctl restart docker.service\n<\/pre>\n<p>Check to see whether the change was honored by reviewing the output of netstat to confirm dockerd is listening on the configured port.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo netstat -lntp | grep dockerd\n<\/pre>\n<p>Configuring remote access with daemon.json<\/p>\n<p>    Set the hosts array in the \/etc\/docker\/daemon.json to connect to the UNIX socket and an IP address, as follows:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n    {\n      &quot;hosts&quot;: &#x5B;&quot;unix:\/\/\/var\/run\/docker.sock&quot;, &quot;tcp:\/\/127.0.0.1:2375&quot;]\n    }\n<\/pre>\n<p>Restart Docker. Check to see whether the change was honored by reviewing the output of netstat to confirm dockerd is listening on the configured port.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n sudo netstat -lntp | grep dockerd\n<\/pre>\n<p>Ref:<br \/>\nhttps:\/\/docs.docker.com\/engine\/install\/debian\/<br \/>\nhttps:\/\/docs.docker.com\/engine\/install\/linux-postinstall\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Set up the repository Update the apt package index and install packages to allow apt to use a repository over HTTPS: $ sudo apt-get update $ sudo apt-get install ca-certificates curl gnupg lsb-release Add Docker\u2019s official GPG key: $ curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo gpg &#8211;dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg Use the following command to set up &#8230; <a title=\"Install Docker on Debian\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2021\/10\/27\/install-docker-on-debian\/\" aria-label=\"Read more about Install Docker on Debian\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,56],"tags":[],"class_list":["post-6211","post","type-post","status-publish","format-standard","hentry","category-docker","category-kb"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/6211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=6211"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/6211\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=6211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=6211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=6211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}