# Container

> A sealed box with a program and everything it needs to run anywhere.

- Level: Basic
- Topics: Cloud, Software
- URL: https://tidbit.legios.com.ar/container/
- In Spanish: [Contenedor](https://tidbit.legios.com.ar/es/container/)

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.

## An analogy

A shipping container. Whatever is inside, every crane, truck and ship knows how to handle the box, so the cargo moves from port to port without being repacked.

## 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.

## Go deeper

- [What is Docker? (official docs)](https://docs.docker.com/get-started/docker-overview/)
- [What is containerization? (AWS)](https://aws.amazon.com/what-is/containerization/)
- [Containerization (Wikipedia)](https://en.wikipedia.org/wiki/Containerization_(computing))

## Related terms

- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [Cloud computing](https://tidbit.legios.com.ar/cloud-computing/): Renting computers over the internet instead of buying your own.
- [Docker](https://tidbit.legios.com.ar/docker/): The tool that made containers easy: package an app once, run it anywhere.
- [Python](https://tidbit.legios.com.ar/python/): A popular programming language known for being easy to read and quick to write.
- [Virtual machine](https://tidbit.legios.com.ar/virtual-machine/): A complete computer made of software, running inside a real one.
- [Operating system](https://tidbit.legios.com.ar/operating-system/): The base software that runs a device and lets every app share its hardware.
- [Kubernetes](https://tidbit.legios.com.ar/kubernetes/): The system that runs and babysits containers across many machines.
- [Amazon ECS and Fargate](https://tidbit.legios.com.ar/amazon-ecs-and-fargate/): AWS runs your containers; with Fargate you never see the servers at all.
