From school-student basics to production-grade deployments โ with interactive diagrams, use cases, and hands-on labs.
Before we get technical, let's use an analogy every student will get.
You build an app on your laptop. It works perfectly. You give it to your friend โ it crashes. Why? Because their computer has different software, different versions, different settings.
Docker lets you pack your app and everything it needs into one tidy box called a Container. The app runs the same everywhere โ your laptop, a server, the cloud.
Think of a shipping dock. Before containers, every cargo item was loaded differently. With shipping containers, one standard box fits every ship, truck, and train. Docker does the same for software.
Three things to remember:
A read-only blueprint or recipe. Like a cookie cutter โ it defines what the container will look like but isn't running yet. Images are stored in registries like Docker Hub.
A running instance of an image. Like a cookie cut from the cutter โ now it exists, it's alive. You can have 100 containers from one image, all running independently.
A simple text file with instructions to build your image. Like a recipe card: "Start with Ubuntu, install Python, copy my code, run this command."
The full picture from your code to a running container.
Both isolate environments โ but in very different ways.
| Feature | ๐ฅ๏ธ Virtual Machine | ๐ณ Docker Container |
|---|---|---|
| Size | GBs per VM | MBs per container |
| Boot time | Minutes | Seconds or less |
| OS overhead | Full OS per VM | Shared host kernel |
| Isolation | Very strong | Process-level (less than VM) |
| Portability | Harder | Very easy (push/pull image) |
| Use case fit | Full OS isolation, legacy apps | Microservices, CI/CD, dev env |
Docker is everywhere in modern software development.
New team member joins. Instead of spending 2 days installing dependencies, they just run docker-compose up and the entire project is running in minutes โ database, backend, frontend, all of it.
Every time code is pushed to GitHub, a Docker container spins up, runs all tests in a clean environment, builds the app, and deploys โ all automatically and reproducibly.
Netflix, Uber, and Amazon run hundreds of small services instead of one giant app. Each service runs in its own Docker container โ independently deployable, scalable, and maintainable.
AWS, Azure, and Google Cloud all support Docker natively. Build once on your laptop, deploy the same container image to the cloud. No surprises โ it runs exactly the same.
Data scientists package models with their exact Python version, CUDA version, and library versions. The model trains the same on any GPU machine without environment conflicts.
Have an old app that needs PHP 5.6 but your server runs PHP 8? Run the old app in a container with its exact environment without breaking anything else on the server.
Step-by-step from zero to your first running container.
Docker Desktop for Windows requires WSL2. Open PowerShell as Administrator and run:
Restart your computer when prompted.
Download Docker Desktop from docker.com/products/docker-desktop. Run the installer and make sure "Use WSL 2 instead of Hyper-V" is checked during setup.
Open Windows Terminal or Command Prompt and verify Docker is working:
๐ If you see "Hello from Docker!" โ you're up and running!
Let's run an Nginx web server in seconds โ no installation needed:
Let's create a simple Python web app and containerize it. Create a folder called myapp and these files:
app.py
requirements.txt
Dockerfile (no file extension!)
Now build and run it:
Real apps have multiple parts โ a web server, a database, a cache. Docker Compose lets you define and run them all with a single file.
Example: Python App + PostgreSQL + Redis
The most important commands, organized by category.
docker run <image>Create and start a containerdocker run -d ...Run in background (detached)docker run -p 8080:80 ...Map host:container portdocker psList running containersdocker ps -aAll containers (incl. stopped)docker stop <name>Gracefully stop containerdocker rm <name>Delete a containerdocker logs <name>View container logsdocker exec -it <name> shEnter running containerdocker pull <image>Download image from Hubdocker imagesList local imagesdocker build -t name .Build image from Dockerfiledocker rmi <image>Delete an imagedocker push name:tagPush to Docker Hubdocker tag img name:tagTag an imagedocker history <image>Show image layersdocker-compose upStart all servicesdocker-compose up -dStart in backgrounddocker-compose downStop & remove containersdocker-compose psList compose servicesdocker-compose logs -fStream logsdocker-compose buildRebuild imagesdocker-compose restartRestart all servicesdocker system pruneRemove all unused datadocker container pruneRemove stopped containersdocker image pruneRemove dangling imagesdocker volume pruneRemove unused volumesdocker statsLive resource usagedocker inspect <name>Full container details (JSON)FROM <image>Base image to start fromWORKDIR /pathSet working directoryCOPY src dstCopy files into imageADD src dstLike COPY, also handles URLs & tarballsRUN <command>Execute during buildCMD ["cmd","arg"]Default command at startupENTRYPOINT [...]Non-overridable startup commandEXPOSE <port>Document which port app usesENV KEY=VALUESet environment variableARG NAME=defaultBuild-time variableVOLUME /pathDeclare persistent mount point