Getting Started
Docker Introduction
Learn Docker — the containerization platform that changed how we build, ship, and run software.
What is Docker?
Docker is a platform for developing, shipping, and running applications in containers. A container is a lightweight, standalone, executable package that includes everything needed to run a piece of software: code, runtime, system tools, libraries, and settings.
Containers vs VMs
| Container | Virtual Machine | |
|---|---|---|
| Size | MBs | GBs |
| Startup | Seconds | Minutes |
| OS | Shares host OS kernel | Full OS |
| Isolation | Process-level | Full virtualization |
| Overhead | Minimal | Significant |
Why Docker?
- "Works on my machine" problem solved: Same environment everywhere
- Isolation: Apps don't interfere with each other
- Reproducibility: Exact same setup in dev, staging, production
- Scalability: Easy to spin up multiple containers
- Microservices: Perfect for containerizing individual services
Key Concepts
- Image: Blueprint/template for a container
- Container: Running instance of an image
- Dockerfile: Instructions to build an image
- Registry: Storage for images (Docker Hub)
Example
bash
# Pull an image from Docker Hub
docker pull nginx
# Run a container
docker run nginx
# Run in detached mode (background)
docker run -d nginx
# Run with port mapping (host:container)
docker run -d -p 8080:80 nginx
# Now visit: http://localhost:8080
# Run interactively
docker run -it ubuntu bash
# List running containers
docker ps
# List all containers (including stopped)
docker ps -a
# Stop a container
docker stop container_id_or_name
# Remove a container
docker rm container_id
# List images
docker images
# Remove an image
docker rmi nginxTry it yourself — BASH