How To configure Docker & Docker-Compose in AWS EC2 [Amazon Linux 2023 AMI]

Freddy Manrique
2 min readJul 12, 2023

--

Sometimes when we try to install Docker and docker-Compose in an AWS AMI Linux Instance you can found with some issue, given that AMI from AWS is based on RedHat but not at all, you can try to install docker using yum but docker-compose is not there if you try something like:

$ sudo yum install docker-compose

No match for argument: docker-compose
Error: Unable to find a match: docker-compose

for that reason the best way to do is with the follow recipe:

Docker:

$-> sudo yum install docker -y
$-> sudo service docker start

# make docker autostart
$-> sudo chkconfig docker on
# I strongly recommend install also: git (sudo yum install -y git)

$-> sudo reboot # only if for you it is neccesary

Docker-Compose

# docker-compose (latest version)
$-> sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
# Fix permissions after download
$-> sudo chmod +x /usr/local/bin/docker-compose
# Verify success
$-> docker-compose version

I hope this can help you, now you can forget about the use of `pip3 install docker-compose` which sometimes can help but is not the best way for AWS Linux AMI ISO.

cheers!

Two Cents (Crontab Installation)

In Amazon Linux AMI SO there is no crontab by default, so might you need it in case you need to set up a cron:

# install
$-> sudo yum install cronie -y
# enable the service
$-> sudo systemctl enable crond.service
# start the service
$-> sudo systemctl start crond.service
# verify success
$-> sudo systemctl status crond | grep Active
Active: active (running) since Tue 2023-05-10 22:37:06 UTC; 15s ago
# also you can:
$-> sudo systemctl status crond.service

Thank you for reading, I hope this guide can help you in the future!

--

--