How to Install Docker on Amazon Linux 2

After doing your initial sudo yum update -y you can install docker with:

sudo amazon-linux-extras install docker

Add the ec2-user to the docker group (to avoid the need to sudo when running docker commands):

sudo usermod -a -G docker ec2-user

Enable the service to start automatically after a reboot, then actually start the service itself:

sudo systemctl enable docker
sudo service docker start

Final check to verify everything looks ok would be docker -v and docker ps -a should result in output like:

[ec2-user@ip-172-27-0-223 ~]$ docker -v
Docker version 18.09.9-ce, build 039a7df
[ec2-user@ip-172-27-0-223 ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[ec2-user@ip-172-27-0-223 ~]$

Note that amazon-linux-extras has an older version of the docker engine, e.g. at the time of this writing the latest available was 19.03, but Amazon's version is 18.09.

Avatar
Sebastien Taggart
Technical Program Manager

The key to everything is mastery of your frame of mind. Everything is relative.

comments powered by Disqus