⚒️ Nico Axtmann

How To Install Docker On Ec2 Instance?

Published on 1 min read

How to install docker on a EC2 instance is probably one of the items that I did various times in the past. Everytime, I had to lookup on the docs or to google. Below you can find a snippet to install docker on a EC2 instance.

# Installs docker
sudo amazon-linux-extras install docker
 
# Starts the service
sudo service docker start
 
# Adds the ec2-user to the docker group
sudo usermod -a -G docker ec2-user
 
# Sets docker to start always when running the instance
sudo chkconfig docker on
 
# Install git - always helpful
sudo yum install -y git
 
# Install docker-compose
# Look up the most recent version at https://github.com/docker/compose/releases
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
 
# Makes docker-compose executable
sudo chmod +x /usr/local/bin/docker-compose