Docker Image
A reusable blueprint that contains code, dependencies, runtime, and setup details.
This page moves from the basic idea of Docker into the mechanics of how Docker packages and runs applications.
A reusable blueprint that contains code, dependencies, runtime, and setup details.
A running instance created from an image.
A text file that gives Docker the instructions needed to build an image.
If you want Nginx to serve your custom index.html, this is enough to create a small image:
FROM nginx:latest
COPY index.html /usr/share/nginx/html/index.html
docker build -t my-nginx-app .
docker run -d -p 8080:80 my-nginx-app
RUN vs CMDRUN is used at build time. CMD is used when the container starts.
Removing a container does not remove the image. The image stays on your machine until you delete it separately.
Each major Dockerfile step can create a layer. Docker can reuse unchanged layers, which makes builds faster.
Next page: Lesson 3 turns these concepts into a real step-by-step app build.