🌐 Detecting your location…
📢 Advertisement — Configure AdSense in Appearance → Customize → AdSense Settings

डॉकर संपूर्ण गाइड 2026: कंटेनर, कंपोज़ और सर्वोत्तम अभ्यास

⏱️2 min read  ·  301 words
Docker Complete Guide 2026: Containers, Compose and Best Practices

डॉकर2026 में एप्लिकेशन बनाने, शिप करने और चलाने का मानक तरीका है। प्रत्येक क्लाउड प्लेटफ़ॉर्म – AWS, GCP, Azure – डॉकर कंटेनर चलाता है। यह मार्गदर्शिका डॉकर कंपोज़ के साथ डॉकर को पहली बार इंस्टॉल करने से लेकर मल्टी-कंटेनर ऐप्स तक कवर करती है।

डॉकर स्थापित करें

# Ubuntu / Debian
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker

# Verify
docker --version
docker run hello-world

मूल अवधारणाएँ

  • छवि:एक कंटेनर के लिए ब्लूप्रिंट (केवल पढ़ने के लिए)
  • कंटेनर:एक छवि का चल रहा उदाहरण
  • डॉकरफ़ाइल:छवि बनाने के निर्देश
  • रजिस्ट्री:छवियों के लिए भंडारण (डॉकर हब, ईसीआर, जीसीआर)

आपकी पहली डॉकरफ़ाइल

# Dockerfile
FROM python:3.12-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

# Build image
docker build -t myapp:latest .

# Run container
docker run -d -p 8000:8000 --name myapp myapp:latest

# View logs
docker logs myapp

# Stop & remove
docker stop myapp && docker rm myapp

आवश्यक डॉकर कमांड

# List running containers
docker ps

# List all containers (including stopped)
docker ps -a

# List images
docker images

# Execute command inside container
docker exec -it myapp /bin/bash

# Copy file from container
docker cp myapp:/app/output.log ./output.log

# Remove all stopped containers + unused images
docker system prune -af

डॉकर वॉल्यूम (निरंतर डेटा)

# Named volume — data persists between container restarts
docker run -d \
  -v postgres_data:/var/lib/postgresql/data \
  -e POSTGRES_PASSWORD=secret \
  --name postgres \
  postgres:16

# Bind mount — mount host directory
docker run -d \
  -v $(pwd)/data:/app/data \
  myapp:latest

डॉकर कंपोज़ – मल्टी-कंटेनर ऐप्स

# docker-compose.yml
services:
  web:
    build: .
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=postgresql://postgres:secret@db:5432/mydb
    depends_on:
      - db
    volumes:
      - .:/app

  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: mydb
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

# Start all services
docker compose up -d

# View logs
docker compose logs -f

# Stop everything
docker compose down

# Rebuild and restart
docker compose up -d --build

मल्टी-स्टेज बिल्ड (छोटी छवियां)

# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json .
RUN npm ci
COPY . .
RUN npm run build

# Stage 2: Production (no dev dependencies)
FROM node:22-alpine AS production
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]

निष्कर्ष

डॉकर “मेरी मशीन पर काम करता है” समस्या को समाप्त करता है। Dockerfile की मूल बातें सीखें, स्थानीय विकास के लिए Docker Compose में महारत हासिल करें, और आप बिना किसी आश्चर्य के लैपटॉप से ​​​​क्लाउड पर लगातार ऐप्स भेजेंगे।

✍️ Leave a Comment

Your email address will not be published. Required fields are marked *

🌐 Read in:🇬🇧 English🇩🇪 Deutsch🇧🇷 Português🇸🇦 العربية🇮🇳 हिन्दी🇧🇩 বাংলা