How to install docker on Amazon Linux2

Make sure you have amazon-linux-extras installed

[root@ip-20-0-0-112 ~]# which amazon-linux-extras
/usr/bin/amazon-linux-extras

If not install amazon-linux-extras using yum

yum -y install amazon-linux-extras

Then install docker using

amazon-linux-extras install docker

So sorry, it was my misunderstanding. My OS is Redhat Linux. I get to install docker by

yum-config-manager --enable rhui-REGION-rhel-server-extras
yum -y install docker 
systemctl start docker
systemctl enable docker
docker version

Install Docker

sudo yum update -y
sudo yum -y install docker

Start Docker

sudo service docker start

Access Docker commands in ec2-user user

sudo usermod -a -G docker ec2-user
sudo chmod 666 /var/run/docker.sock
docker version