Dockerfiles पढ़ना और कंटेनर चलाना

Containerization और Virtualization अवधारणाएँ

Julia Ostheimer

Freelance AI Consultant

Docker शब्दों का रिकैप

 

Dockerfile से Docker कंटेनर तक

Containerization और Virtualization अवधारणाएँ

Docker instructions बनाम Docker commands

  • Docker instructions बताती हैं कि Docker image कैसे बनती है

Dockerfile में Docker instructions

  • Docker commands: Command Line Interface (CLI) के जरिए कमांड्स

CLI में Docker commands

Containerization और Virtualization अवधारणाएँ

Dockerfile का फ़ॉर्मैट

 

Dockerfile - Comment

Containerization और Virtualization अवधारणाएँ

Dockerfile का फ़ॉर्मैट

 

Dockerfile - Instruction

Containerization और Virtualization अवधारणाएँ

Dockerfile का फ़ॉर्मैट

 

Dockerfile - Docker instruction का Command

Containerization और Virtualization अवधारणाएँ

Dockerfile का फ़ॉर्मैट

 

Dockerfile - Docker instruction का Argument

Containerization और Virtualization अवधारणाएँ

Dockerfiles में क्रम

  • क्रमवार निष्पादन
  • Dockerfile की शुरुआत:
    • मेटाडेटा
    • टिप्पणियाँ
    • आर्ग्युमेंट्स
    • FROM instruction
Containerization और Virtualization अवधारणाएँ

Docker instructions का ओवरव्यू

  • महत्वपूर्ण Docker instructions
    • FROM
    • COPY
    • RUN
    • ENTRYPOINT
Containerization और Virtualization अवधारणाएँ

FROM instruction

  • किसी मौजूदा Docker image को निर्दिष्ट करता है
  • वह image बताता है जिस पर हम बिल्ड कर रहे हैं
    • "Starting point"  

Syntax:

FROM <name_of_image>

Example:

# Define the image on which to build
FROM python:3.10
Containerization और Virtualization अवधारणाएँ

COPY instruction

  • फ़ाइलें या डायरेक्टरीज़ कॉपी करता है
    • स्रोत (<source>) से गंतव्य (<destination>) तक
    • आगे की Docker instructions के लिए ज़रूरी फ़ाइलें  

Syntax:

COPY <source> <destination>

Example:

# फ़ाइलें/फोल्डर्स कंटेनर के मुख्य फोल्डर में कॉपी करें
COPY . .
Containerization और Virtualization अवधारणाएँ

RUN instruction

  • कंटेनर के भीतर कोई कमांड चलाता है
    • कोई भी कमांड जो CLI में चल सकती है

 

Syntax:

RUN <command>

Example:

# एप्लिकेशन की dependencies इंस्टॉल करें
RUN pip install -r requirements.txt
Containerization और Virtualization अवधारणाएँ

ENTRYPOINT instruction

  • कंटेनर का डिफ़ॉल्ट व्यवहार तय करता है
    • स्टार्ट पर चलने वाली कमांड बताता है
    • कंटेनर का प्राथमिक उद्देश्य  

Syntax:

ENTRYPOINT ["command", "argument"]

Example:

# कंटेनर शुरू होने पर स्क्रिप्ट चलाएँ
ENTRYPOINT ["python", "hello_world.py"]
Containerization और Virtualization अवधारणाएँ

Instructions जोड़कर Dockerfile बनाना

# Define the image on which to build
FROM python:3.10
Containerization और Virtualization अवधारणाएँ

Instructions जोड़कर Dockerfile बनाना

# Define the image on which to build
FROM python:3.10

# Copy files/folders to the main folder of the container
COPY . .
Containerization और Virtualization अवधारणाएँ

Instructions जोड़कर Dockerfile बनाना

# Define the image on which to build
FROM python:3.10

# Copy files/folders to the main folder of the container
COPY . .

# Install the application's dependencies
RUN pip install -r requirements.txt
Containerization और Virtualization अवधारणाएँ

Instructions जोड़कर Dockerfile बनाना

# Define the image on which to build
FROM python:3.10

# Copy files/folders to the main folder of the container
COPY . .

# Install the application's dependencies
RUN pip install -r requirements.txt

# Run the script when the container starts
ENTRYPOINT ["python", "hello_world.py"]
Containerization और Virtualization अवधारणाएँ

Docker build कमांड

  • Dockerfile से Docker image बनाता है
    • Dockerfile बिल्ड के कॉन्टेक्स्ट (<context>) में होना चाहिए
    • CLI के जरिए Docker client से कमांड रूप में चलता है

 

Syntax:

docker build <context>
Containerization और Virtualization अवधारणाएँ

Docker run कमांड

  • Docker image से Docker container बनाता और चलाता है
    • Docker image को आर्ग्युमेंट (<name_of_image>) के रूप में देना होता है
    • CLI के जरिए Docker client से कमांड रूप में चलता है

 

Syntax:

docker run <name_of_image>
Containerization और Virtualization अवधारणाएँ

अभ्यास करते हैं!

Containerization और Virtualization अवधारणाएँ

Preparing Video For Download...