Skip to content

Instantly share code, notes, and snippets.

@ibqn
Last active August 1, 2024 14:49
Show Gist options
  • Save ibqn/c477a3613ec02d1470d7978fb27e73da to your computer and use it in GitHub Desktop.
Save ibqn/c477a3613ec02d1470d7978fb27e73da to your computer and use it in GitHub Desktop.
Install Docker on Ubuntu, Debian and Raspbian (Raspberry Pi 3), respectively

Install docker

prerequisites, install them if not already present

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

add docker's GPG key

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

verify fingerprint, if you want, which should be 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

sudo apt-key fingerprint 0EBFCD88

add repository if on Ubuntu or Debian only

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

On Raspbian this method does not work, you can add a repository manually by running

sudo bash -c "echo 'deb [arch=armhf] https://download.docker.com/linux/raspbian stretch stable' > /etc/apt/sources.list.d/docker.list"
sudo apt update

install docker

sudo apt-get install docker-ce docker-ce-cli containerd.io

list versions available in the repo

apt-cache madison docker-ce

a specific version can be installed as well by

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

verify that Docker CE is installed correctly by running the hello-world image.

sudo docker run hello-world

if you would like to use Docker as a non-root user, consider adding your user to the docker group

sudo usermod -aG docker your-user

Purge docker

Uninstall docker

sudo apt-get purge docker-ce

Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

sudo rm -rf /var/lib/docker

Remove the GPG key

sudo apt-key del 0EBFCD88

Install docker compose binary

An alternative way for installing docker compose is to use pip within the virtual environment i.e. for reference python -m pip install docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose

make this binary file executable

sudo chmod +x /usr/local/bin/docker-compose

and create a symbolic link to the /usr/bin folder

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment