Container
A sealed box with a program and everything it needs to run anywhere.
A container packages a program together with everything it needs to run: the libraries, the settings, the exact version of the language runtime. That package, called an image, runs the same on your laptop, on a colleague's machine and on a server in the cloud. Docker is the tool that made containers popular, and a Dockerfile is the recipe that builds an image.
Before containers, "it works on my machine" was a daily problem: the server had a different Python version, a missing library, a setting nobody remembered. A container ends that argument, because the environment travels with the code. It also starts in seconds and is far lighter than a full virtual machine, since containers share the operating system of the machine that hosts them.
Today most web services ship as containers. One server can run dozens of them, isolated from each other, and tools like Kubernetes or Amazon ECS and Fargate decide where each one runs and restart it if it dies.
Keep in mind
- An image is the frozen package; a container is a running copy of it.
- Registries like Docker Hub or Amazon ECR are where images are stored and shared.
- Containers share the host's operating system, so they start fast and use little memory.
- Lighter than a virtual machine, with somewhat weaker isolation.