Junior — Middle
Explain the difference between Dockerfile and Docker Image.
sobes.tech AI
Answer from AI
Dockerfile is a text file with instructions describing how to build a Docker Image. It specifies the base image, commands for installing software, copying files, configuring the environment, etc.
Docker Image is the result of building a Dockerfile. It is a ready-to-run template containing all necessary layers and dependencies to create a container.
Example:
# Dockerfile
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y curl
COPY app.sh /app.sh
CMD ["/app.sh"]
Building this Dockerfile yields a Docker Image that can be run as a container.