Getting Started with Docker¶
What You'll Learn
How to install Docker CE, configure it for a homelab environment, and establish good patterns from the start.
Installation¶
# Remove old versions
sudo apt remove docker docker-engine docker.io containerd runc 2>/dev/null
# Add Docker's official GPG key and repo
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
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
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add your user to docker group
sudo usermod -aG docker $USER
Post-Install Configuration¶
Configure Docker Daemon¶
/etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"default-address-pools": [
{
"base": "172.20.0.0/16",
"size": 24
}
],
"metrics-addr": "0.0.0.0:9323",
"experimental": true
}
Why This Matters
- Log rotation prevents Docker from eating all your disk space
- Custom address pools avoid conflicts with your LAN subnets
- Metrics endpoint enables Prometheus scraping for monitoring
First Compose Stack¶
docker-compose.yml
services:
whoami:
image: traefik/whoami
container_name: whoami
ports:
- "8080:80"
restart: unless-stopped
If you see output with container details, you're in business.
Next Steps¶
- Set up a reverse proxy (Traefik or Nginx Proxy Manager)
- Deploy your first real service
- Establish a backup strategy for container data
- Set up monitoring with Prometheus + Grafana