Installing Docker in Debian 9

Update the installed packages to the latest version:

sudo apt update
sudo apt upgrade

OUTPUT:

[email protected]:~# apt update
Hit:1 http://security.debian.org/debian-security stretch/updates InRelease
Get:2 https://download.docker.com/linux/debian stretch InRelease [44.8 kB]         
Ign:3 http://ftp.us.debian.org/debian stretch InRelease                              
Hit:4 http://ftp.us.debian.org/debian stretch-updates InRelease
Get:5 https://download.docker.com/linux/debian stretch/stable amd64 Packages [5,447 B]  
Hit:6 http://ftp.us.debian.org/debian stretch Release                                
Fetched 50.3 kB in 0s (93.8 kB/s)       

Install the dependencies necessary to add a new repository over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg2

OUTPUT:

[email protected]:~#  apt install apt-transport-https ca-certificates curl software-properties-common gnupg2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ca-certificates is already the newest version (20161130+nmu1+deb9u1).
ca-certificates set to manually installed.
The following additional packages will be installed:
gir1.2-glib-2.0 gir1.2-packagekitglib-1.0 libcap2-bin libcurl3 libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-bin libgstreamer1.0-0 libpackagekit-glib2-18 libpam-cap libpolkit-agent-1-0

Import the repository’s GPG key using the following curl command:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

OUTPUT:

[email protected]:~# curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
OK

Add the Docker APT repository to your system’s software repository list by typing:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

OUTPUT:

[email protected]:~#  add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Now Install Docker apt package:

sudo apt install docker-ce

OUTPUT:

[email protected]:~# apt install docker-ce
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.9.0-8-amd64/updates/dkms/
depmod...
DKMS: install completed.
Setting up linux-headers-amd64 (4.9+80+deb9u6) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ..

Once the installation is completed the Docker service will start automatically.

systemctl status docker

OUTPUT:

[email protected]:~#  systemctl status docker
    ● docker.service - Docker Application Container Engine
    Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Active: active (running) since Mon 2019-01-07 08:57:14 EST; 2min 11s ago
    Docs: https://docs.docker.com
    Main PID: 5919 (dockerd)
    Tasks: 12
    Memory: 30.7M
    CPU: 501ms
    CGroup: /system.slice/docker.service
       └─5919 /usr/bin/dockerd -H unix://

Last Modified: January 07 2019 20:36:07