Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bonno/b5cf766cea40ffd18157bf0d069676e2 to your computer and use it in GitHub Desktop.
Save Bonno/b5cf766cea40ffd18157bf0d069676e2 to your computer and use it in GitHub Desktop.
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
##
## https://docs.docker.com/install/linux/docker-ce/ubuntu
##
# Install packages to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
# Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Use the following command to set up the stable repository. You always need the stable repository,
# even if you want to install builds from the edge or test repositories as well. To add the edge or test
# repository, add the word edge or test (or both) after the word stable in the commands below.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt-get update
sudo apt install docker-ce
# Add current user to docker group. Need reboot
echo "Add user '$USER' to group 'docker'. Log out and log back in so that your group membership is re-evaluated."
sudo usermod -aG docker $USER
# Get latest docker compose released tag
docker_compose_version="$(git ls-remote https://github.com/docker/compose | grep "refs/tag" | grep -oP "[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n1)"
# Install docker-compose
sudo sh -c "curl -L https://github.com/docker/compose/releases/download/$docker_compose_version/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
sudo chmod +x /usr/local/bin/docker-compose
sudo sh -c "curl -L https://raw.githubusercontent.com/docker/compose/$docker_compose_version/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
# Install docker-cleanup command
cd /tmp
git clone https://gist.github.com/76b450a0c986e576e98b.git
cd 76b450a0c986e576e98b
sudo mv docker-cleanup /usr/local/bin/docker-cleanup
sudo chmod +x /usr/local/bin/docker-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment