Skip to content
StackDecode
BeginnerLesson 6 of 26

Writing a Dockerfile

A Dockerfile is a script that builds an image, one instruction per layer.

dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "main.py"]
  • FROM: the base image to start from.
  • WORKDIR: sets the working directory (creating it).
  • COPY: copies files from your project into the image.
  • RUN: runs a command at build time.
  • CMD: the default command at run time.