Installing Docker
Before we containerize our e-commerce app, we need Docker running on your machine. The installation is straightforward on any operating system.
Docker Desktop
Docker Desktop is the easiest way to get started. It includes:- Docker Engine - The runtime that runs containers
- Docker CLI - Command-line interface
- Docker Compose - Tool for multi-container apps
- Docker Desktop GUI - Visual management (optional)
Installation by Platform
macOS
- Download Docker Desktop from [docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop)
- Open the
.dmgfile - Drag Docker to Applications
- Launch Docker from Applications
- Wait for the whale icon in the menu bar to stop animating
Windows
- Download Docker Desktop from [docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop)
- Run the installer
- Enable WSL 2 when prompted (recommended)
- Restart your computer
- Launch Docker Desktop
Linux (Ubuntu/Debian)
# Update packages
sudo apt-get update
# Install prerequisites
sudo apt-get install ca-certificates curl gnupg
# Add Docker's GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add Docker repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add your user to the docker group (avoids needing sudo)
sudo usermod -aG docker $USER
Log out and back in for the group change to take effect.
Verify Installation
Open a terminal and run:
docker --version
Expected output:
Docker version 24.0.7, build afdd53b
Your version may differ - anything 20+ is fine.
Now run the classic test:
docker run hello-world
Expected output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
...
Hello from Docker!
This message shows that your installation appears to be working correctly.
If you see this, Docker is ready to go.
Understanding Docker Architecture
Docker uses a client-server architecture:
┌──────────────────────────────────────────────────────┐
│ Your Computer │
│ │
│ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Docker CLI │ ──API─▶ │ Docker Daemon │ │
│ │ │ │ (dockerd) │ │
│ │ $ docker │ │ │ │
│ │ run │ │ ┌───────────────┐ │ │
│ │ build │ │ │ Containers │ │ │
│ │ pull │ │ └───────────────┘ │ │
│ └─────────────┘ │ ┌───────────────┐ │ │
│ │ │ Images │ │ │
│ │ └───────────────┘ │ │
│ └─────────────────────┘ │
└──────────────────────────────────────────────────────┘
Docker CLI - What you type commands into
Docker Daemon - Background service that does the work
Images - Templates for creating containers
Containers - Running instances of images
When you run docker run hello-world:
- CLI sends command to daemon
- Daemon checks for
hello-worldimage locally - If not found, pulls from Docker Hub
- Daemon creates and runs a container from the image
- Container output is sent back to CLI
Essential Commands Check
Verify these commands work:
# Check Docker Compose (for multi-container apps)
docker compose version
# List running containers (empty for now)
docker ps
# List all containers (including stopped)
docker ps -a
# List downloaded images
docker images
Configure Resources (Optional)
For e-commerce development, you might need more resources. In Docker Desktop:
- Click the gear icon (Settings)
- Go to Resources
- Recommended minimums:
- Memory: 4GB+
- Disk: 20GB+
For our e-commerce stack (API + database + cache), 4GB RAM is comfortable.
Quick Troubleshooting
"Cannot connect to Docker daemon"- Make sure Docker Desktop is running (whale icon in system tray)
- On Linux:
sudo systemctl start docker
- On Linux: Add yourself to docker group:
sudo usermod -aG docker $USER, then log out/in - Or prefix commands with
sudo
- Docker runs in a Linux VM on these systems
- Allocate more RAM in Docker Desktop settings
- Use volume caching options (covered later)
Key Takeaways
- Docker Desktop is the easiest installation method
- docker --version verifies installation
- docker run hello-world tests the full system
- Docker uses a client-server architecture
- Daemon runs containers, CLI sends commands
Next, let's run real containers and explore how they work!