# devops / containers / docker 101
Introduction to Docker
If you’ve ever faced the dreaded “It works on my machine but not on yours” problem — Docker is the hero you need. It packages your code, PHP runtime, and all dependencies into an isolated environment.
The Engine Under the Hood
Docker operates on a client-server architecture. They communicate via REST API, Unix sockets, or a network interface.
👉 Analogy: You (the client) say “Make tea!” ☕ and the kitchen (the daemon) makes it.
🖥️ Docker Client
The tool we use to interact with Docker. It runs commands like docker run or docker pull and can communicate with local or remote Daemons.
⚡ Docker Daemon
The engine running in the background. It is fully responsible for building images, running containers, and managing networks and volumes.
Core Puzzle Pieces
FROM ubuntu RUN apt-get update && apt-get install -y nginx CMD ["nginx", "-g", "daemon off;"]
The Container Lifecycle
- pull
Download a read-only Image from a Registry (like Docker Hub).
docker pull ubuntu - create
Initialize a Container, adding a temporary read-write layer on top of the image.
Ephemeral by default - network
Connect the container to a virtual network and assign it a unique IP.
Bridged networking - interact
Execute your code, open a terminal, or expose ports to the host machine.
docker run -p 80:80
Common Docker Commands
Whether you are building infrastructure or troubleshooting an application, you will spend most of your time interacting with the Docker CLI using these image and container commands.
🥊 Docker vs Virtual Machine
| Feature | Docker (Container) | Virtual Machine (VM) |
|---|---|---|
| Startup Time | Seconds ⚡ | Minutes 🕒 |
| Resource Usage | Lightweight 🪶 | Heavy 💻 |
| OS Requirement | Shares Host OS | Needs Full Guest OS |
| Performance | Faster 🚀 | Slower 🐢 |
| Isolation | Process-level | Hardware-level |
Want to run 10 microservices on a single server without overhead? → Use containers.
Want to run a Windows application natively on a Linux host server? → Use a Virtual Machine.