Container
- In Turkish
- Konteyner
In short
A container is a lightweight, isolated package that bundles an application with its dependencies and runs it on the host's shared operating system kernel.
What is a container?
A container is a standard unit of software that includes an application's code together with everything it needs to run, such as the runtime, system libraries, and settings. Because the package is self-contained, the application behaves the same wherever the container runs, whether on a laptop, a server, or in the cloud.
Containers rely on features of the Linux kernel: namespaces give each container its own isolated view of processes, files, and networking, and cgroups (control groups) limit how much CPU and memory it can use. Every container starts from an image, a read-only template built in layers, and a container runtime such as containerd or CRI-O starts and stops it.
Think of apartments in a building: each apartment has its own locked door, rooms, and utility meter, but all of them share the same foundation and plumbing. In the same way, containers are isolated from one another but share the host's operating system kernel, which makes them fast to start and efficient to run in large numbers.
The most common confusion is between containers and virtual machines. A virtual machine includes an entire guest operating system on top of a hypervisor, so it is heavier and slower to boot but more strongly isolated. Containers share the host kernel, so they are often measured in megabytes instead of gigabytes and start in about a second or less.
At a glance
Key takeaways
- A container packages an app with its dependencies so it behaves the same everywhere.
- Containers share the host operating system kernel, unlike virtual machines.
- Linux namespaces provide isolation, and cgroups limit resources.
- Containers are created from images that follow the OCI standard.
- Docker builds and runs containers; Kubernetes manages them at scale.
Example
# Download the nginx image and start a container from it
docker run -d --name web -p 8080:80 nginx
# List running containers
docker ps
# Open a shell inside the running container
docker exec -it web sh
# Stop and remove the container (the image stays on disk)
docker stop web && docker rm webReaders ask
What is the difference between a container and a virtual machine?
A virtual machine runs a full guest operating system on virtualized hardware, while a container shares the host's kernel and isolates only the application. Containers are lighter and faster to start; virtual machines offer stronger isolation.
Are containers the same as Docker?
No. Containers are a general technology, and Docker is one popular set of tools for building and running them. Images built with Docker follow the OCI standard and can also run with other tools such as Podman or containerd.
Can containers run on Windows and macOS?
Yes. Tools like Docker Desktop run Linux containers inside a lightweight virtual machine on macOS and Windows, and Windows also supports native Windows containers.
Often compared
See also
- DockerDevOps & Cloud, p. 17Docker is an open-source platform for packaging an application and everything it needs into a container that runs the same way on any machine.
- KubernetesDevOps & Cloud, p. 32Kubernetes is an open-source system that automates deploying, scaling, and managing containerized applications across a cluster of machines.
- Virtual MachineDevOps & Cloud, p. 53A virtual machine is a software-based computer that runs its own operating system on shared physical hardware, isolated from other machines on the same host.
- DevOpsDevOps & Cloud, p. 14DevOps is a set of practices and a culture that brings software development and IT operations together to deliver software faster and more reliably.
- MicroservicesSoftware Architecture, p. 27Microservices are an architectural style where an application is split into small, independently deployable services that communicate over a network.
- ServerlessDevOps & Cloud, p. 47Serverless is a cloud model in which the provider runs your code on demand, manages all the servers, scales automatically, and bills only for actual use.
- HypervisorOperating Systems, p. 15A hypervisor is software that creates and runs virtual machines, sharing one physical computer's CPU, memory, and devices among several isolated guest systems.
- Twelve-Factor AppSoftware Architecture, p. 46A twelve-factor app is a web application built according to twelve practices that make it portable, easy to deploy, and simple to scale in the cloud.
Sources
Spotted a mistake or something missing on this page?Suggest an edit