Skip to content

Instantly share code, notes, and snippets.

@npearce
Last active November 11, 2024 13:09
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: https://aws.amazon.com/amazon-linux-2/release-notes/

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 https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

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

@OlliKantola
Copy link

Works like a charm. Thank you.

@itbrunoms
Copy link

The best anwser!!

@ShamalMuneer007
Copy link

THANK YOU!!!!

@kevindai007
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

@316usman
Copy link

316usman commented Jan 8, 2024

Thanks docker-compose works great

@jonassteinberg1
Copy link

@tuancuongth88
Copy link

Thanks

@NicholasMarks2024
Copy link

Thank you.

@realtebo
Copy link

thank you !

should we still install manually docker compose?

@realtebo
Copy link

I got this

docker: 'compose' is not a docker command.

@aidanhor-n
Copy link

If this doesn't work for you for whatever reason, add it to PATH

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

two years later, my savior

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