Installing Docker on an AWS EC2 instance

How to install Docker and Docker compose on an Linux EC2 instance

Posted on June 10, 2019

ssh into the ec2 instance

ssh -i [path to pem file] ec2-user@[Public DNS]

Install Docker

Install docker and set permissions.

yum update -y // Update pre-installed packages
sudo su // Elevate privileges
yum-config-manager --enable rhui-REGION-rhel-server-extras // Enable Amazon Linux Extras
sudo yum install -y docker // Install docker
sudo service docker start // Start docker
sudo groupadd docker // Create a user group called docker
sudo usermod -a -G docker ec2-user // Add your user to that group

Log out and back in so these changes take effect. If this doesn’t work you’ll need to reboot linux with

reboot -p

Install Docker Compose


sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null // Install docker-compose
sudo chmod +x /usr/local/bin/docker-compose // Set permissions
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose // SymLink
docker-compose --version // Check docker-compose version