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. लक्षात ठेवा: 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 (open ports). curl localhost चालते पण browser timeout = security group, container नव्हे.

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 वाढवा

समजलं का? Why Docker on EC2 = developer vs server-side empty engine fight; Instagram / Netflix / Infosys “suppose”; hello-world proof. पुढे: स्वतःची image त्याच engine वर.

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.