Stop 07 · Containers & DockerTopics · 1/9

Docker Fundamentals

Part of the DevOps Roadmap

In short

Your app runs on your laptop but breaks on the server because of a different Node version or a missing library. Containers pack the app with everything it needs, so it runs the same everywhere.

Packaging an application and its dependencies into a portable, isolated container that runs identically anywhere — the technology that made 'it works on my machine' a largely solved problem.

The mascot packs a full meal into a steel tiffin and hands it to a delivery man with a bicycle.

Think of it like this

The packed tiffin box

A tiffin box carries the whole meal: dal, rice, roti, pickle, even the spoon. The delivery man doesn't need your kitchen to serve it. A container image is that tiffin: your code plus its runtime and libraries, ready to open on any machine.

Watch it happen

What happens on docker run

docker CLI
Docker engine
Registry
Container

run nginx:1.27

1/6The CLI is just a client. It sends your command to the Docker engine running in the background.

The big ideas

What you need to know

Image vs container

An image is the packed tiffin, read-only. A container is one running copy of it. One image can run as many containers.

Not a virtual machine

Containers share the host's Linux kernel. No full OS to boot, so they start in seconds and use far less memory than VMs.

Isolation by the kernel

Linux namespaces give each container its own view of processes, network and files. cgroups cap its CPU and memory.

Containers are disposable

Anything written inside a container is lost when you remove it. Keep data in volumes, config in environment variables.

See it in code

Walk through the code

bash
1# Pull an image and run it as a container2docker pull nginx:1.273docker run -d --name web -p 8080:80 nginx:1.274 5# See what's running, then read its logs6docker ps7docker logs web8 9# Stop and remove it when you're done10docker stop web && docker rm web

1/3-d runs it in the background, --name gives a friendly name, -p maps host port 8080 to the container's port 80.

Open http://localhost:8080 after the run command and you'll see the nginx welcome page, served from inside the container.

Save yourself the pain

Common mistakes

Oops

Using the :latest tag everywhere because it's the default.

Do this instead

Pin a version like nginx:1.27. latest can change under you, so two machines may quietly run different code.

Oops

Treating a container like a pet server: SSH in, install things, edit files by hand.

Do this instead

Change the image instead and recreate the container. Anything done by hand inside disappears on the next deploy.

Your mission

Your first three containers

~20 min

Quick check

You start three containers from the same nginx image. What does Docker store on disk?

Go deeper

  1. 1Install Docker and run your first container from a public image.
  2. 2Learn the difference between an image (a blueprint) and a container (a running instance).
  3. 3Practice the basic docker commands: run, ps, stop, rm, images.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge