Install Docker on Debian/Ubuntu

Posted by Jason Feng on May 2, 2019

A quick reference for myself regarding the steps to install Docker on Debian/Ubuntu.

Install docker on Debian

Install dependencies for docker

1
2
3
4
5
6
sudo apt-get -y install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common 

Install Docker’s official GPG key

1
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -

Check that the GPG fingerprint of the Docker key you downloaded matches the expected value

1
sudo apt-key fingerprint 0EBFCD88

Add the stable Docker repository

1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")    $(lsb_release -cs) stable"

Install docker

1
2
sudo apt-get update
sudo apt-get -y install docker-ce

Configure Docker to run as a non-root user

1
sudo usermod -aG docker $USER

Exit the shell and SSH to the VM again

Check docker is installed correctly and confirm that you can run Docker as a non-root user

1
docker run hello-world