SSH to your Amazon Linux 2 EC2 instance, and follow the steps:

$ sudo yum update -y
$ sudo amazon-linux-extras install docker
$ sudo systemctl enable docker
$ sudo systemctl start docker
$ sudo usermod -aG docker ec2-user  # Optional, allows you to run `docker` commands without `sudo`
$ sudo reboot

That’s it!

I work as a freelancer, so if you don’t want to do that kind of things yourself or don’t have the time, just drop me a line to hire me.