Skip to content

Instantly share code, notes, and snippets.

@danielreiser
Last active July 27, 2021 10:01
Show Gist options
  • Save danielreiser/7daf56f50b8fc0278998ccceeb950885 to your computer and use it in GitHub Desktop.
Save danielreiser/7daf56f50b8fc0278998ccceeb950885 to your computer and use it in GitHub Desktop.
Install docker and docker-compose on an ubuntu based EC2 instance in AWS
# Update all package lists and update ubuntu
sudo apt-get -y update
sudo apt-get -y dist-upgrade
# Add the docker repository to make it available via apt-get install and update the package lists again
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Setup permissions correctly
sudo usermod -aG docker $(whoami)
# Install jq to be able to parse json and get the latest docker compose version
sudo apt-get install -y jq
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)
# Install docker compose und make the bin executable
sudo curl -L "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Now logout to make docker ps available in you shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment