Middle
What are the main instructions that make up a Dockerfile?
sobes.tech AI
Answer from AI
The main instructions of a Dockerfile include:
FROM— specifies the base image to start the build.RUN— executes commands in the container during build (e.g., installing packages).COPYandADD— copy files from the build context into the image.CMD— sets the default command to run when the container starts.ENTRYPOINT— sets the main executable for the container.ENV— sets environment variables.WORKDIR— sets the working directory for subsequent instructions.EXPOSE— declares the ports the container listens on.VOLUME— declares mount points for volumes.
Example Dockerfile for a Python application:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]