Junior — Middle
What are the goals of creating a Dockerfile in the process of containerizing applications?
sobes.tech AI
Answer from AI
A Dockerfile is a text file containing a set of instructions that describe how to build a Docker image for an application.
Goals of creating a Dockerfile:
- Automate image building: allows reproducible creation of containers with the required environment and application.
- Define environment: sets the base image, installs dependencies, copies files, and configures the app.
- Portability: an image built from a Dockerfile can run on any machine with Docker without additional setup.
- Simplify deployment: containers created from the image ensure consistent behavior across environments.
Example of a simple Dockerfile for a Python app:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
This file describes how to build an image with Python, install dependencies, and run the app.