Ravindra BagaleCourses & study guides Track your progress

Guides

Amazon Linux EC2 पर Docker Install (शुरुआती)

Read this guide in: English · मराठी · हिंदी

Why server पर Docker चाहिए? क्योंकि developers और operations के बीच असली problem है। Developers कहते हैं “laptop पर चलता है।” Operations — server side वाला employee — नया Amazon Linux 2023 EC2 खोलता है और shared runtime नहीं होता। हर deploy copy-paste पर लौटता है। उस EC2 पर Docker install करने से दोनों पक्षों को वही engine मिलता है — container cloud server पर चल सकता है।

दोस्तों, पहले खाली EC2 सुबह देखो। फिर install → start → run चिपक जाएगा।

संक्षिप्त उत्तर

  1. Developer — laptop पर चलने वाला app बनाता है।
  2. Operations — server-side employee जिसे EC2 पर भरोसेमंद चीज़ चलानी है।
  3. Problem — container engine नहीं; हाथ से copy; version drift।
  4. Docker on EC2 — install, start, docker group, docker run hello-world।
  5. Pocket: install → start → enable → group → new login → run.

Language: English · मराठी · हिंदी

Docker on EC2 क्यों?

  1. Developers app pack करेंगे ताकि laptop और server मिलें।
  2. Operations को वह package चलाने वाला engine चाहिए।
  3. न हो तो हर release zip नाटक में लौटे।

पहले: Amazon Linux 2023 EC2 (launch EC2), ec2-user से SSH (SSH guide)। Learning के लिए free-tier t3.micro / t2.micro काफ़ी — df -h देखो। Invented AWS prices नहीं।

Problem? Suppose we are…

Suppose we are building Instagram (like updates)

Profile API laptop पर चलता है। Operations नए EC2 पर docker टाइप करता है — command not found — files हाथ से copy। Library versions अलग। Users को टूटा page।

Suppose we are working at Netflix and we are giving updates

Netflix-style services हर host पर वही runtime चाहते हैं। Server पर container engine न हो तो “laptop पर चला” → “लाखों के लिए टूटा।”

Suppose you are working in Infosys on a client project

Client EC2 lab देता है। उनका operations team known runtime install + prove चाहता है — हर release day नई install नहीं।

Docker image becomes a running container on EC2 The docker run command asks the Docker daemon to pull the nginx image from Docker Hub and start a container named web. A browser request on port 80 passes the security group, Docker forwards it to the container, and the 200 OK response goes back. Image is the read-only package; container is the running copy. Docker Hub image registry Browser SG :80 EC2 · Docker daemon $ docker run -d -p 80:80 --name web nginx Imagenginx Container"web" :80 Image = read-only package · Container = running copy run pull image GET / 200 OK

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.

Docker on EC2 कैसे जवाब देता है

sudo yum update -y
sudo yum install docker -y
docker --version
sudo service docker start
sudo systemctl enable docker
sudo usermod -aG docker ec2-user
exit
# SSH again
groups
docker run hello-world

Optional: docker run -d -p 80:80 nginx + security group में HTTP TCP 80। curl localhost चले पर browser timeout = security group।

Ravindra Bagale's Tip

usermod के बाद permission denied? नया SSH login चाहिए। Browser timeout + curl OK = security group। याद रखो।

Common errors

Pain कारण Fix
permission denied docker.sock Group / नया login नहीं usermod + new SSH
Cannot connect to daemon Service बंद sudo service docker start
address already in use Port 80 लिया Host web रोकें या -p 8080:80
Browser timeout, curl OK Security group TCP 80 allow
no space left Images भरे prune; EBS बढ़ाएँ

Samajla ka? Why Docker on EC2 = developer vs server-side empty engine fight; Instagram / Netflix / Infosys “suppose”; hello-world proof। आगे: अपनी image उस 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.