Docker packages your code, its dependencies and its runtime into one image.
That image runs the same way on your laptop and in production.
It removes the entire class of failures that begin with works on my machine.
A Dockerfile is the recipe, listing the base image, the dependencies and the command.
Each instruction creates a layer, and unchanged layers are cached between builds.
Ordering matters, so copy the dependency list and install before copying your source.
Otherwise every code change reinstalls everything.
Multi-stage builds compile in one image and copy only the result into a small final one.
That keeps images small, which speeds deployment and reduces attack surface.
Pin versions, since latest means the image changes underneath you without warning.
Do not bake model weights into the image if they are large.
Mount them or fetch them at startup so the image stays manageable.
GPU access needs the NVIDIA container runtime, which is a common first stumbling block.
Never put secrets in the image, since anyone who can pull it can read them.
It is the unit of deployment for essentially every cloud platform.