Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

@amitkumar-2
Copy link

amitkumar-2 commented Sep 25, 2022

thank you bro.....

@GDalonso
Copy link

GDalonso commented Oct 16, 2022

Thank you

@shashankChndkr
Copy link

shashankChndkr commented Oct 17, 2022

Thanks!

@seyslee
Copy link

seyslee commented Oct 21, 2022

Thank you bro, it works well!

@vlad8x8
Copy link

vlad8x8 commented Nov 1, 2022

just pulled amazonlinux:2

sh-4.2# service docker start
sh: service: command not found
sh-4.2# sudo service docker start
sh: sudo: command not found

@hotyes
Copy link

hotyes commented Nov 2, 2022

$ sudo usermod -a -G docker ec2-user
$ id ec2-user
# Reload a Linux user's group assignments to docker w/o logout
$ newgrp docker

@btskloud
Copy link

btskloud commented Nov 3, 2022

@JaydotMurf
Copy link

JaydotMurf commented Nov 7, 2022

Awesome!

@Alzavio
Copy link

Alzavio commented Nov 25, 2022

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

@vlad8x8
Copy link

vlad8x8 commented Nov 25, 2022

be sure to restart your machine.

restart after what? right after I started it?
it can't find even sudo

@btskloud
Copy link

btskloud commented Nov 25, 2022

be sure to restart your machine.

restart after what? right after I started it? it can't find even sudo

You must have signed in as a non-sudoer

@btskloud
Copy link

btskloud commented Nov 25, 2022

be sure to restart your machine.

restart after what? right after I started it? it can't find even sudo

You must have signed in as a non-sudoer

Looking at your thread, you don’t have to start docker.. I will install it on Amazon Linux when I have extra time and reply with the steps.

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