Lessons
Get Docker
Introduction
Docker basic concepts
- What is a container?
- Container क्या होता है?
- What is an image?
- Docker Image क्या होती है?
- What is a registry?
- Docker Registry क्या है?
- What is Docker Compose?
- Docker Compose क्या है?
Docker Commands
Docker Image क्या होती है?
Docker Image क्या होती है?
Docker Image एक ब्लूप्रिंट (template) होती है, जिससे container बनाया जाता है। आप इसे ऐसे समझ सकते हैं — जैसे किसी इमारत को बनाने से पहले उसका नक्शा (blueprint) तैयार किया जाता है, उसी तरह किसी container को चलाने से पहले उसकी image तैयार की जाती है।
Docker Image में क्या होता है?
एक Docker Image में वह सब कुछ होता है जो किसी Application को चलाने के लिए आवश्यक होता है:
- Application का कोड
- जरूरी Libraries और Dependencies
- Configuration Files
- Base OS Files (जैसे: Ubuntu, Alpine, Debian आदि)
Image और Container का रिश्ता
| तुलना | Docker Image | Docker Container |
|---|---|---|
| Nature | Static (Fixed) | Running (Live) |
| क्या है? | Blueprint / Template | Running instance of image |
| Example | nginx:latest | वह nginx server जो चल रहा है |
| कमांड | docker pull | docker run |
उदाहरण
# Nginx image डाउनलोड करना docker pull nginx # Image से container बनाना और चलाना docker run -d -p 8080:80 nginx
Image कैसे बनती है?
Docker Image आम तौर पर एक Dockerfile से बनाई जाती है। यह एक साधारण text file होती है जिसमें लिखा होता है कि Image कैसे तैयार करनी है।
# बेस image FROM python:3.9 # Working directory सेट करें WORKDIR /app # Code copy करें COPY . /app # Dependencies install करें RUN pip install -r requirements.txt # App चलाने की command CMD ["python", "app.py"]
फिर इसे build करने के लिए यह कमांड चलाते हैं:
docker build -t my-python-app .
Docker Image = Container का ब्लूप्रिंट
इसमें App + Dependencies + Configuration शामिल होते हैं
Image से ही Container बनता और चलता है
Image को आप share भी कर सकते हैं (Docker Hub या private registry में)