Install Docker CE and Docker Compose on Debian and Ubuntu based Linux distributions

  • Uninstall older versions of Docker, docker.io, or docker-engine.
sudo apt-get remove docker docker-engine docker.io containerd runc

Update the apt package index:

sudo apt-get update

Install packages to allow apt to use a repository over HTTPS:

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

Add Docker’s official GPG key:

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

Set up the stable repository.

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

Update the apt package index:

sudo apt-get update

Install the latest version

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

To use Docker as a non-root user add the user to the “docker” group:

sudo usermod -aG docker $USER

Run this command to download the current stable release of Docker Compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply executable permissions to the binary:

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

Note: If the command docker-compose fails after installation,

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Add docker-compose bash completion

sudo curl -L https://raw.githubusercontent.com/docker/compose/1.25.3/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

log out and back in for this to take effect!