Ravindra BagaleCourses & study guides Track your progress

Guides

शुरुआती के लिए Docker Compose

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

Why Docker Compose चाहिए? क्योंकि app एक से ज़्यादा process हो तो developers और operations में problem आता है। Developers को web front और Redis cache चाहिए। Operations — server side — दो लंबी docker run lines, भूली networks, और cache hostname नहीं मिलता। Compose = एक docker-compose.yml: docker compose up stack जलाता है; docker compose down बंद करता है।

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

  1. Developer — laptop पर app + cache साथ।
  2. Operations — server-side person जिसे बिना folklore वही pair चलाना है।
  3. Problem — दो docker run; drift; containers में गलत hostname।
  4. Compose — एक YAML, up, ps, logs, down।
  5. Pocket: one file, one up, one down.

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

Problem? Suppose we are…

Suppose we are building Instagram (like updates)

Feed API को Redis cache। Developer दो commands से चलाता है। Container में localhost गलत। Operations EC2 पर laptop network दोहरा नहीं पाता।

Suppose we are working at Netflix and we are giving updates

छोटा local stack (app + cache) service name से बात करे। Compose वह network document करता है।

Suppose you are working in Infosys on a client project

Client operations एक file से lab stack शुरू चाहता है। Word doc की दो mystery docker run release day पर फेल।

Need Docker (EC2 install), Compose plugin।

Docker Compose multi-service stack One docker-compose.yml defines web and cache services on a shared network. docker compose up starts the stack so services talk by name. docker-compose.yml services · ports · network web nginx:alpine ports 8080:80 cache redis:alpine internal only network web → cache by service name docker compose up -d One file for the lab stack — not two mystery docker run lines

One docker-compose.yml starts web and cache on a shared network; services talk by name with docker compose up.

Docker Compose services Terminal-style teaching diagram of docker compose up -d and docker compose ps for web and cache.

Terminal-style teaching diagram: docker compose up -d and docker compose ps for web (published port) and cache (internal).

Compose कैसे जवाब देता है

docker compose version
mkdir composelab && cd composelab
cat > docker-compose.yml <<'EOF'
services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
  cache:
    image: redis:alpine
EOF
docker compose up -d
docker compose ps
curl -I http://localhost:8080
docker compose down

Containers में service name cache — localhost नहीं। Cache/db के लिए अक्सर public ports: नहीं।

Ravindra Bagale's Tip

हर port internet पर मत खोलो। App cache से service name से बोले। याद रखो।

Learn it properly

Samajla ka? Why Compose = multi-container fight; Instagram / Netflix / Infosys “suppose”; एक YAML, up, down। Kubernetes से पहले यह practice करो।

Frequently asked questions

What is Docker Compose?

A tool that starts multi-container apps from one YAML file.

docker compose vs docker-compose?

Modern Docker uses the plugin form docker compose (space). The old hyphen binary may still exist.

Do I need Kubernetes for two containers?

No. Compose is enough for local and small server stacks.

Where do ports go?

ports: maps host:container. Internal service-to-service traffic often needs no public publish.

What is a service?

A named container definition in the Compose file (for example web or db).

How do I rebuild after code changes?

docker compose up -d --build to rebuild images then restart.