Skip to content

Instantly share code, notes, and snippets.

Last active April 19, 2024 12:35
Show Gist options
  • Save npearce/6f3c7826c7499587f00957fee62f8ee9 to your computer and use it in GitHub Desktop.
Save npearce/6f3c7826c7499587f00957fee62f8ee9 to your computer and use it in GitHub Desktop.
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See:

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user

Make docker auto-start

sudo chkconfig docker on

Because you always need it....

sudo yum install -y git

Reboot to verify it all loads fine on its own.

sudo reboot

docker-compose install

Copy the appropriate docker-compose binary from GitHub:

sudo curl -L$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

NOTE: to get the latest version (thanks @spodnet): sudo curl -L$(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

Copy link

works great!! THANKS A LOT!

Copy link

sudo curl -L$(uname -s)-$(uname -m) -o /usr/bin/docker-compose && sudo chmod +x /usr/bin/docker-compose && docker-compose --version

Copy link

For me, uname -s returned Linux , but the download URL has linux, so converted to lowercase and updated curl to -

sudo curl -L$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) -o /usr/bin/docker-compose && sudo chmod 755 /usr/bin/docker-compose && docker-compose --version


Copy link

@omarelweshy oh thanks a lot
that is for me, uname -s returned Linux, too.

Copy link

vincenthsh commented Mar 3, 2023

for compose v2

# install for all users
# DOCKER_CONFIG=/usr/local/lib/docker
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

Copy link

Showrin commented Mar 8, 2023

Thank you.

Copy link

This saved me, thank you

Copy link

Geczy commented Apr 27, 2023

@vincenthsh 's solution worked for me as sudo

Copy link

MarwenAouiti commented May 29, 2023

wget$(uname -s)-$(uname -m)
sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose
sudo chmod -v +x /usr/local/bin/docker-compose

Copy link

sudo curl -L$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

For me, uname -s returned Linux, but the download URL has linux so please replace it.
Also, uname -m returned x86_64 so replace that as well

sudo curl -L -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

Copy link

Had an issue around the permissions command.
sudo usermod -a -G docker ec2-user

permission denied while trying to connect to the Docker daemon socket at .....

This seemed to be the fix:
sudo usermod -aG docker $USER

Copy link

Works like a charm. Thank you.

Copy link

The best anwser!!

Copy link


Copy link

Thanks a lot, but for this command
sudo amazon-linux-extras install docker
i believe it should change to
sudo yum install docker

Copy link

316usman commented Jan 8, 2024

Thanks docker-compose works great

Copy link

Copy link


Copy link

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment