Docker Installation on AWS EC2
While practicing DevOps, I wanted to set up Docker on an AWS EC2 instance. I decided to document the exact steps I followed. These are my personal learning notes, shared in case someone else is trying the same.
Steps I Followed
1. Launch EC2 Instance
Selected Amazon Linux 2 AMI.
Connected to the instance through MobaXTerm.
2. Check Docker Availability
docker info
Output showed command not found, which means Docker was not installed.
3. Switch to Root and Update Packages
sudo su
sudo yum update -y
4. Install Docker
sudo yum install docker -y
5. Start Docker Service
sudo service docker start
6. Verify Installation
docker info
This time I got permission denied. Reason: the default ec2-user does not have Docker permissions.
7. Add User to Docker Group
sudo usermod -aG docker ec2-user
8. Restart Session
exit
exit
Then I reconnected to the instance.
9. Final Checks
docker -v
docker images
Now Docker was installed and working.
What I Learned
Errors are part of the process; they usually point towards what is missing.
Adding the user to the Docker group is necessary to avoid permission issues.
Writing down steps makes troubleshooting and revisiting the setup much easier.