Getting Started with Docker
Docker · Reference cheat sheet
Getting Started with Docker
Docker · Reference cheat sheet
📋 Overview
Docker packages apps and dependencies into images and runs them as containers. Use it for reproducible environments, local stacks, and deployment units.
🔧 Core concepts
| Idea | Meaning |
|---|---|
| Image | Immutable filesystem + metadata template |
| Container | Running (or stopped) instance of an image |
| Dockerfile | Build recipe for an image |
| Registry | Image store (Docker Hub, GHCR, …) |
| Compose | Multi-container app definition |
| Command | Purpose |
|---|---|
docker version | Client/server versions |
docker pull | Download image |
docker run | Create + start container |
docker ps | List running containers |
docker build | Build from Dockerfile |
💡 Examples
Run nginx:
docker run --rm -p 8080:80 nginx:alpineBuild and run:
docker build -t myapp:dev .
docker run --rm -p 9000:9000 myapp:devShell into a container:
docker exec -it <container> sh⚠️ Pitfalls
- Binding only to container localhost is fine; publishing ports needs
-p host:container. - Data in the writable container layer is lost when the container is removed — use volumes.
- Running as root inside images increases risk — prefer non-root users in production images.