Stop 16 · Docker & ContainersTopics · 1/9

Docker Basics

Part of the Backend Developer Roadmap

In short

"It works on my machine" stops being an excuse with Docker. You pack your app with everything it needs, and it runs the same on your laptop, your friend's and the server.

A containerization platform that packages an app with all its dependencies into a portable, consistent unit that runs identically on any machine — solving the classic 'works on my machine' problem.

The blob packs rice, dal and rotis into a shiny multi-tier steel tiffin carrier.

Think of it like this

Maa's steel tiffin

Maa packs rice, dal, sabzi and rotis into a sealed steel tiffin. Whether you open it in the hostel, a train or the office, it's the same meal, nothing missing. Docker packs your code, Node version and libraries into one box that opens the same anywhere.

Watch it happen

What happens on docker run

docker CLI
Docker engine
Registry
Container

run -p 8080:80 nginx

1/5The CLI is just a client. It asks the Docker engine (a background service) to run nginx.

The big ideas

What you need to know

Image vs container

An image is the packed, read-only box. A container is a running copy of it. One image, many containers.

Lighter than a VM

Containers share the host's Linux kernel instead of booting a whole OS, so they start in seconds and use less memory.

Isolated, not invisible

Each container gets its own files, processes and network, but you choose which ports and folders to share.

Disposable by design

Containers are meant to be thrown away and recreated. Anything you need to keep goes in a volume.

See it in code

Walk through the code

bash
1# Is Docker installed and running?2docker version3 4# Download an image and start a container from it5docker run -d --name web -p 8080:80 nginx:alpine6 7# What's running?8docker ps9 10# Read its logs, then stop and remove it11docker logs web12docker stop web && docker rm web

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

Open 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

Thinking a container is a tiny virtual machine you SSH into and update by hand.

Do this instead

Change the image and recreate the container. Manual changes inside are lost when it's replaced.

Oops

Using the latest tag everywhere.

Do this instead

Pin a version tag, like nginx:1.27-alpine, so a surprise upgrade doesn't break you.

Your mission

Your first three containers

~15 min

Quick check

You run the same image three times. What do you get?

Go deeper

  1. 1Install Docker and run a public image, e.g. `docker run hello-world`.
  2. 2Learn the core vocabulary: image, container, Dockerfile, registry.
  3. 3Containerize a simple Node.js app you've already built.

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