{"id":3995,"date":"2019-08-14T23:11:50","date_gmt":"2019-08-14T20:11:50","guid":{"rendered":"https:\/\/kifarunix.com\/?p=3995"},"modified":"2020-08-09T10:45:14","modified_gmt":"2020-08-09T07:45:14","slug":"install-and-use-docker-on-debian-10-buster","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-use-docker-on-debian-10-buster\/","title":{"rendered":"Install and Use Docker on Debian 10 Buster"},"content":{"rendered":"\n<p>In this guide, we are going to learn how to install and use Docker on Debian 10 Buster. <a rel=\"noreferrer noopener\" aria-label=\"Docker (opens in a new tab)\" href=\"https:\/\/docs.docker.com\/\" target=\"_blank\">Docker<\/a> is a platform that utilizes the OS-level virtualization to provide a way of packaging applications into standardized, isolated and lightweight units called <strong>containers<\/strong> complete with all the dependencies and libraries required for their functionality. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install and Use Docker on Debian 10 Buster<\/h2>\n\n\n\n<p>In this tutorial, we are going to learn how to install the Docker Engine &#8211; Community on Debian 10.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Update Your System<\/h3>\n\n\n\n<p>Update and upgrade your system packages before you can proceed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt update\nsudo apt upgrade<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-using-the-repository\">Install Docker CE Repository<\/h3>\n\n\n\n<p>Docker CE is not available on the default Debian 10 Buster repos. Hence, you need to install them so that can be able to install Docker CE.<\/p>\n\n\n\n<p>Run the command below to install the packages required for pulling Docker CE packages over HTTPS.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common<\/code><\/pre>\n\n\n\n<p>Install Docker APT repository signing key.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo apt-key add -<\/code><\/pre>\n\n\n\n<p>Install Docker CE APT repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo add-apt-repository \"deb [arch=amd64] https:\/\/download.docker.com\/linux\/debian $(lsb_release -cs) stable\"<\/code><\/pre>\n\n\n\n<p>Run system package update.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Docker CE on Debian 10 Buster<\/h3>\n\n\n\n<p>Once you have created the repositories, you can install docker and its required components.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt <code>install docker-ce docker-ce-cli containerd.io<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Running Docker Service on Debian 10 Buster<\/h3>\n\n\n\n<p>After installation, Docker is started and enabled to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status docker<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u25cf docker.service - Docker Application Container Engine\n   Loaded: loaded (\/lib\/systemd\/system\/docker.service; enabled; vendor preset: enabled)\n   Active: active (running) since Wed 2019-08-14 14:11:07 EDT; 22min ago\n     Docs: https:\/\/docs.docker.com\n Main PID: 16977 (dockerd)\n    Tasks: 10\n   Memory: 89.9M\n   CGroup: \/system.slice\/docker.service\n           \u2514\u250016977 \/usr\/bin\/dockerd -H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl is-enabled docker\nenabled<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Running Docker as non-root User<\/h3>\n\n\n\n<p>By default, docker requires root privileges to run. Hence, if you are running it as an ordinary user with no sudo rights, add that user to <strong>docker<\/strong> group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo usermod -aG docker USER<\/code><\/pre>\n\n\n\n<p>Where USER is your non-privileged user. For example, to add a non-root user called amos to <strong>docker<\/strong> group,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo usermod -aG docker amos<\/code><\/pre>\n\n\n\n<p><strong>Next, log out from your system for your new group membership to take effect and login again.<\/strong><\/p>\n\n\n\n<p>You should now be able to run docker with no <strong>'permission denied while trying to connect to the Docker daemon socket...<\/strong>' errors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"test-docker-installation\">Test Docker installation<\/h3>\n\n\n\n<p>Verify that you can run docker without sudo privileges by running a simple Docker image called <strong>hello-world<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker run hello-world<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Unable to find image 'hello-world:latest' locally\nlatest: Pulling from library\/hello-world\n1b930d010525: Pull complete \nDigest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f\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...<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Using Docker on Debian 10 Buster<\/h3>\n\n\n\n<p>Docker has a command line interface tool called <strong>docker<\/strong>. The command line syntax for docker command is;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker [OPTIONS] COMMAND<\/code><\/pre>\n\n\n\n<p>If you run docker with no options nor commands, it displays all the options and command usage.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>...\nManagement Commands:\n  builder     Manage builds\n  config      Manage Docker configs\n  container   Manage containers\n  context     Manage contexts\n  engine      Manage the docker engine\n  image       Manage images\n  network     Manage networks\n  node        Manage Swarm nodes\n  plugin      Manage plugins\n  secret      Manage Docker secrets\n  service     Manage services\n  stack       Manage Docker stacks\n  swarm       Manage Swarm\n  system      Manage Docker\n  trust       Manage trust on Docker images\n  volume      Manage volumes\n...<\/code><\/pre>\n\n\n\n<p>To find more information on a command and its usage, simply run;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker COMMAND --help<\/code><\/pre>\n\n\n\n<p>For example;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker build --help<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Running Docker Images<\/h3>\n\n\n\n<p>While testing our Docker installation above, we ran an image called <strong>hello-world<\/strong>. When an image is ran, a container is launched. If the docker image being ran is not available locally, they are pulled from the <a rel=\"noreferrer noopener\" aria-label=\"Docker Hub (opens in a new tab)\" href=\"https:\/\/hub.docker.com\/\" target=\"_blank\">Docker Hub<\/a> registry. From Docker hub, you can search and pull and use a Docker container that has been created by the community. Docker Hub is the best place to start Dockering with before you can start to build your own images.<\/p>\n\n\n\n<p>As an example of running a docker image, we are going to learn how to pull, install and run Debian Linux image on our docker.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Search for Docker Image on Docker Hub<\/h4>\n\n\n\n<p>Docker Hub has 100,000+ container images from software vendors, open-source projects, and the community. Let us for example search for Debian container image.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker search debian<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>NAME                                                 DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED\nubuntu                                               Ubuntu is a Debian-based Linux operating sys\u2026   9821                &#91;OK]                \ndebian                                               Debian is a Linux distribution that's compos\u2026   3187                &#91;OK]                \narm32v7\/debian                                       Debian is a Linux distribution that's compos\u2026   59                                      \nitscaro\/debian-ssh                                   debian:jessie                                   25                                      &#91;OK]\nsamueldebruyn\/debian-git                             a minimal docker container with debian and g\u2026   21                                      &#91;OK]\narm64v8\/debian                                       Debian is a Linux distribution that's compos\u2026   20                                      \nmultiarch\/debian-debootstrap                         multiarch ports of debian-debootstrap           9                                       \ni386\/debian                                          Debian is a Linux distribution that's compos\u2026   9                                       \neboraas\/debian\n...<\/code><\/pre>\n\n\n\n<p>To download the Debian container image from the registry, simply run;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker pull debian<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Using default tag: latest\nlatest: Pulling from library\/debian\n4ae16bd47783: Pull complete \nDigest: sha256:2f04d3d33b6027bb74ecc81397abe780649ec89f1a2af18d7022737d0482cefe\nStatus: Downloaded newer image for debian:latest\ndocker.io\/library\/debian:latest<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">List Available Docker Images<\/h4>\n\n\n\n<p>To list available images, use <strong>docker image<\/strong> or <strong>docker images ls<\/strong> command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker image ls<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\ndebian              latest              85c4fd36a543        19 hours ago        114MB\nhello-world         latest              fce289e99eb9        7 months ago        1.84kB<\/code><\/pre>\n\n\n\n<p>As you can see, we have two images that we have already pulled from the docker registry.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Running a Docker Container Image<\/h3>\n\n\n\n<p>Once you have the Docker container image, you can run it using the <strong>docker run<\/strong> command. The syntax for <strong>docker run<\/strong> command is;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><code>docker run [OPTIONS] IMAGE [COMMAND] [ARG...]<\/code><\/pre>\n\n\n\n<p> To simply run the Debian container we pulled from the registry, simply execute;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker run -it debian<\/code><\/pre>\n\n\n\n<p>The <strong>-i<\/strong> and <strong>-t<\/strong> options used provides an interactive shell and allocate a pseudo-tty when you run the Debian container image.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>root@820d3232134b:\/#<\/code><\/pre>\n\n\n\n<p>You are now inside your Debian container image. You can now run any other task as you would on a virtual machine. For example;<\/p>\n\n\n\n<p>Verify the version of your Debian server;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@820d3232134b:\/# cat \/etc\/os-release \nPRETTY_NAME=\"Debian GNU\/Linux 10 (buster)\"\nNAME=\"Debian GNU\/Linux\"\nVERSION_ID=\"10\"\nVERSION=\"10 (buster)\"\nVERSION_CODENAME=buster\nID=debian\nHOME_URL=\"https:\/\/www.debian.org\/\"\nSUPPORT_URL=\"https:\/\/www.debian.org\/support\"\nBUG_REPORT_URL=\"https:\/\/bugs.debian.org\/\"\nroot@820d3232134b:\/# <\/code><\/pre>\n\n\n\n<p>Create Users on your Debian 10 container;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@f10c8c02e501:\/# useradd -m amos\nroot@f10c8c02e501:\/# passwd amos\nNew password: \nRetype new password: \npasswd: password updated successfully\nroot@f10c8c02e501:\/# usermod -aG sudo amos<\/code><\/pre>\n\n\n\n<p>To exit your container, just press ctrl+d or exit.<\/p>\n\n\n\n<p>To list all running Docker containers, before you exit a container, open another terminal and  execute;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker ps<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\nf5afa1afb260        debian              \"bash\"              11 seconds ago      Up 10 seconds                           objective_swirles<\/code><\/pre>\n\n\n\n<p>The command <strong>docker ps<\/strong> is also similar to, <strong>docker containers ls<\/strong>.<\/p>\n\n\n\n<p>If you have exited the container, <strong>docker ps<\/strong> will not show anything. Therefore, to list all containers including the ones that are not running, simply execute;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker ps -a<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                         PORTS               NAMES\nf5afa1afb260        debian              \"bash\"              6 minutes ago       Exited (0) 5 seconds ago                           objective_swirles\nf10c8c02e501        debian              \"bash\"              13 minutes ago      Exited (0) 10 minutes ago                          cocky_zhukovsky\n820d3232134b        debian              \"bash\"              21 minutes ago      Exited (0) 13 minutes ago                          charming_heyrovsky\n1a960a624a8d        hello-world         \"\/hello\"            About an hour ago   Exited (0) About an hour ago                       goofy_zhukovsky<\/code><\/pre>\n\n\n\n<p>To start and exited container in an interactive mode, get the container ID or NAME from the <strong>docker ps -a<\/strong> command and run;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker start -i containerID\/NAME<\/code><\/pre>\n\n\n\n<p>To start the container in the background, run the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker start containerID\/NAME<\/code><\/pre>\n\n\n\n<p>To stop the container;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker stop containerID\/NAME<\/code><\/pre>\n\n\n\n<p>To delete container;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker rm containerID\/NAME<\/code><\/pre>\n\n\n\n<p>Well, that is just it on our basic guide on how to install and use Docker on Debian 10 Buster.<\/p>\n\n\n\n<p>Related Tutorials;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-debian-10-buster-on-virtualbox\/\" target=\"_blank\">Install Debian 10 Buster on VirtualBox<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-fedora-30-workstation-on-virtualbox\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install Fedora 30 Workstation on VirtualBox<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-ibm-qradar-ce-v7-3-1-on-virtualbox\/\" target=\"_blank\">How to Install IBM QRadar CE v7.3.1 on VirtualBox<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/autostart-virtualbox-vms-on-system-boot-on-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">AutoStart VirtualBox VMs on System Boot on Linux<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we are going to learn how to install and use Docker on Debian 10 Buster. Docker is a platform that utilizes the<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[1076,1077],"tags":[1078,1039,1079,1081,1080],"class_list":["post-3995","post","type-post","status-publish","format-standard","hentry","category-containers","category-docker","tag-containers","tag-debian-10-buster","tag-docker","tag-docker-hub","tag-docker-images","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3995"}],"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=3995"}],"version-history":[{"count":2,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3995\/revisions"}],"predecessor-version":[{"id":6662,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3995\/revisions\/6662"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=3995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=3995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=3995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}