Docker GPG Key

To add the GPG key for the official docker repository, curl -fsSL | sudo apt-key add -


Ubuntu 18.04

If you are using Ubuntu 18.04, run the following commands to add the required Docker repository to apt, upgrade your package lists and grab the docker-ce package.

sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable edge"
sudo apt-get -y update && sudo apt-get -y upgrade
sudo apt install docker-ce
Ubuntu 19.04

If you are using Ubuntu 19.04 or any similar bleeding-edge version, you will likely need to append the test branch to the newly configured repository above.
sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable edge test"

You should be able to less /etc/apt/sources.list and see the new repository has been added to the end of our file. Generally, the sources.list file should contain the following -

# /etc/apt/sources.list modifications
# Example taken from Ubuntu 19.04 system


deb disco-security multiverse
deb [arch=amd64] disco stable test edge
# deb-src [arch=amd64] disco stable edge test
# deb-src disco-security multiverse

Ubuntu 20.04

If you haven't already, be sure to update your package list by running sudo apt-get -y update && sudo apt-get -y upgrade - this will both update your list of packages, and upgrade your currently installed packages to the newest available versions. Then run sudo apt install to install Docker.

Docker Compose

To install compose on Ubuntu, run the following commands

sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Download and install the docker-machine binaries
base= &&
  curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
  sudo install /tmp/docker-machine /usr/local/bin/docker-machine

docker-machine version

# Using the version confirmed by the above command within the next line..
for i in docker-machine-prompt.bash docker-machine-wrapper.bash docker-machine.bash
  sudo wget "$base/contrib/completion/bash/${i}" -P /etc/bash_completion.d

# Tell bash where to find the new file
source /etc/bash_completion.d/docker-machine-prompt.bash