Installing Docker and Docker Compose on Ubuntu

Basic steps and script to get Docker and Docker Compose up and running quickly

You may want to check out the step before this, Building a Linux Open-Source GIS Environment with Windows: Part 1 - WSL!

Installing Docker and Docker-Compose

Docker lets you run containers on your computer (or Subsystem in this case).

Docker-compose is a simple Docker orchestrator that’s great for small systems.

  1. Docker and digitalocean have put together some great information on this, and I could never do better, so I used their documents to put together a script:
  2. https://docs.docker.com/engine/install/ubuntu/
  3. https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04
  4. You can paste this into Terminal
export user=$(whoami)
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update && sudo apt-get install \
    docker-ce \
    docker-ce-cli \
    containerd.io

sudo usermod -aG docker ${USER}
# This step will ask you for your password again
su - ${USER}
# start docker (This is needed with WSL)
sudo service docker start
# exit out of the su command
exit
  1. Let’s install docker-compose
  2. Get the latest version number of Docker Compose
      export DOCKERCOMPOSEVERSION=$(curl -s https://github.com/docker/compose/releases/latest | perl -pe 's/^.+\/tag\/(.+?)">.+/\1/g')
    
  3. Install the latest docker-compose
    sudo curl -L "https://github.com/docker/compose/releases/download/${DOCKERCOMPOSEVERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
    sudo chmod +x /usr/local/bin/docker-compose
    
  4. Verify your version by running this command
    docker-compose --version
    
  5. You now have Docker and docker-compose installed!