What is a Dockerfile?
Options
- A log file that records the steps of a build
- A text file with step-by-step instructions to build an image (Correct option)
- A configuration file for the Docker settings of the computer
- A list of the containers that are currently running
Answer
A text file with step-by-step instructions to build a Docker image
Why
A Dockerfile is a recipe: start from a base image, copy files, install dependencies, define the start command. docker build runs it and produces an image.
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]Remember
Dockerfile = recipe for an image.