Sobes.tech
Junior

Как собрать образ с использованием Docker?

sobes.tech AI

Answer from AI

From a Dockerfile.

# Use a base image
FROM python:3.9-slim

# Set working directory
WORKDIR /app

# Copy dependencies file
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy application source code
COPY . .

# Define command to run
CMD ["python", "app.py"]

Build command:

docker build -t my-python-app .
  • docker build: command to build an image.
  • -t my-python-app: tags the image.
  • .: path to the directory with Dockerfile.