Skip to content
BENIBIX Learn

Container

Infrastructure📦 ContainersContainer Basics

Also known as Software Container, Linux Container, Containerized App

A sealed box that holds an app and all it needs. It runs the same anywhere.

Think of it like

It is like a lunch box. The whole meal is packed inside, so it travels well.

Example

Lucy's web app works on her laptop but breaks on the server. She packs it into a container, and now it runs the same in both places.

Why it matters

It ends the old excuse that it works on my machine. The same box runs in testing and in the real world.

Definition

A container is a sealed box for one app. It holds the app's code and every file the app needs to run. Because it brings its own files, it runs the same on a laptop and on a server. Many containers can share one machine, and each stays in its own space. They are lighter than a virtual machine, because they share the machine's core system, the kernel.

Example code

console
$ docker run -d -p 8080:80 nginx
$ curl -s localhost:8080 | grep title
<title>Welcome to nginx!</title>
One line starts a web server in a container. Port 8080 on the laptop leads to port 80 inside it.
Containers share one kernel, so they are slim. A virtual machine carries a whole system of its own.

Common mistake

Saving files inside the container and hoping they stay. When the box is removed, its files go with it.

Key takeaways

  1. 1
    Self-contained. It carries every file the app needs.
  2. 2
    Kept apart. Each container sees only its own space.
  3. 3
    Easy to replace. Throw one away and start a fresh copy.

Compare