Install Docker on Amazon Linux EC2 (Beginners)
Read this guide in: English · मराठी · हिंदी
Why do we need Docker on the server? Because there is a real problem between developers and operations. Developers say “it runs on my laptop.” Operations — the employee on the server side — opens a fresh Amazon Linux 2023 EC2 box with no shared runtime. Every deploy falls back to copy-paste. Installing Docker on that EC2 gives both sides the same engine so a container can run on the cloud server.
Friends, first see the empty EC2 morning. Then install → start → run will stick.
Quick answer
Hold this vertical picture:
- Developer — builds an app that works on the laptop.
- Operations — server-side employee who must run something reliable on EC2.
- The problem — no container engine; hand copy; version drift.
- Docker on EC2 — install, start, docker group,
docker run hello-world. - Pocket line: install → start → enable → group → new login → run.
Language: English · मराठी · हिंदी
Why do we need Docker on EC2?
- Developers will package the app so laptop and server match.
- Operations on the server side needs an engine that can run that package.
- Without it, every release returns to zip drama.
Before you start: Amazon Linux 2023 EC2 (launch EC2), SSH as ec2-user (SSH guide). Free-tier eligible t3.micro / t2.micro is enough for learning — watch disk with df -h. No invented AWS prices.
What does operations do here?
- Operations is the server-side employee.
- Today: SSH in, install the engine, prove
hello-world, later run the team’s image. - Developers own the app code — both share the same runtime story.
What is the problem? Suppose we are…
Suppose we are building Instagram (like updates)
Suppose the profile API works on the developer laptop. Operations SSHs to a new EC2, types docker — command not found — and copies files by hand. Library versions differ. Users see a broken page.
Suppose we are working at Netflix and we are giving updates
Suppose Netflix-style services expect the same runtime on every host. Without a container engine on the server, “works on my laptop” becomes “broke for millions.”
Suppose you are working in Infosys on a client project
Suppose the client gives you an EC2 lab. Their operations team expects you to install a known runtime and prove it — not invent a one-off install every release day.
docker run pulls an image (read-only package) from Docker Hub and starts a container (running copy) on EC2. A request on port 80 passes the security group to the container.
How Docker on EC2 answers that same fight
sudo yum update -y
sudo yum install docker -y
docker --version
sudo service docker start
sudo systemctl enable docker
sudo service docker status
sudo usermod -aG docker ec2-user
exit
# SSH in again
groups # must list docker
docker run hello-world
docker ps -a
docker images
Optional public smoke test:
docker run -d -p 80:80 --name web --restart unless-stopped nginx
curl -I http://localhost
Allow HTTP TCP 80 in the security group (open ports 80/443). If curl localhost works but the browser times out, fix the security group — not the container.
Ravindra Bagale's Tip
Permission denied right after usermod? You need a new SSH login. exit, connect again, groups. Browser timeout + working curl = security group. Lakshat theva.
Common errors — story pain then fix
| Pain from the stories | Likely cause | Fix |
|---|---|---|
| permission denied on docker.sock | Not in group / no new login | usermod + new SSH |
| Cannot connect to the Docker daemon | Service stopped | sudo service docker start |
| bind: address already in use | Host uses port 80 | Stop host web server or -p 8080:80 |
| Browser timeout, curl OK | Security group | Allow TCP 80 |
| no space left on device | Images filled disk | docker system df; prune; grow EBS |
Learn it properly
- AWS twin: Install Docker on Amazon Linux 2023
- Next: First Dockerfile · Docker Compose
- Launch EC2 · SSH
Samajla ka? Why Docker on EC2 = empty-stove fight between developer and server-side operations; Instagram / Netflix / Infosys “suppose”; hello-world proves the engine. Next: your own image on that stove.
Frequently asked questions
Which OS does this guide use?
Amazon Linux 2023 on EC2 with the yum package docker.
Why permission denied on docker.sock?
Your user is not in the docker group, or you did not open a new SSH session after usermod.
Is docker group as powerful as root?
Yes — only add trusted users.
Do I need Compose on day one?
No. Learn docker run first; Compose is the next guide.
Where is the longer AWS-focused install guide?
See also install-docker-on-amazon-linux-2023-ec2 under AWS guides for extra Compose notes.
Which instance size for learning?
A free-tier eligible t3.micro or t2.micro is enough; watch disk with df -h.