Unable to install docker on AWS Linux AMI
Solution in context of the image - Amazon Linux 2 AMI
One may need to remove the packages they installed using docker provided links
use the command here to remove all of that:-
sudo rm /etc/yum.repos.d/docker-ce.repo
And use the link given by AWS to install the docker here - https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
The content for that commands in that link are as below:-
Connect to your instance(Amazon Linux 2 AMI).
Update the installed packages and package cache on your instance.
sudo yum update -y
Install the most recent Docker Community Edition package.
sudo amazon-linux-extras install docker
Start the Docker service.
sudo service docker start
Add the ec2-user to the docker group so you can execute Docker commands without using sudo.
sudo usermod -a -G docker ec2-user
Log out and log back in again to pick up the new docker group permissions. You can accomplish this by closing your current SSH terminal window and reconnecting to your instance in a new one. Your new SSH session will have the appropriate docker group permissions.
Verify that the ec2-user can run Docker commands without sudo.
docker info
Use amazon-linux-extras to install docker
# install
sudo rm /etc/yum.repos.d/docker-ce.repo # if you have already tried in the wrong way
sudo amazon-linux-extras install docker
# enable on boot and start daemon
sudo systemctl enable docker
sudo systemctl start docker
# correct permissions
sudo usermod -a -G docker $USER
newgrp docker
docker ps