Setting Up Your Docker Home Lab: PART II - Installation and First Steps

Summary

In this blog post, we explore the setup of a modern Docker home lab, perfect for IT students and tech enthusiasts. We'll guide you through creating a workspace featuring Docker containers and essential tools like Portainer and Homepage. This setup ensures a productive and organized environment for managing your Docker projects. Whether you're new to Docker or looking to optimize your current setup, this guide will provide valuable insights and practical tips to enhance your home lab.


Ready to turn that old laptop or your Windows 11 machine into a powerful development server?

In our first post, we covered why Docker home labs are perfect for IT students and what you can accomplish with modest hardware. Now it's time to get our hands dirty with the actual installation and setup.

By the end of this guide, you'll have Docker running smoothly, Portainer managing your containers through a beautiful web interface, and Homepage providing a dashboard to access all your services. We'll cover both paths – dedicated Linux servers and Windows 11 with WSL2 – so you can follow along regardless of your chosen setup.

Path 1: Setting Up Docker on Linux

Choosing Your Linux Distribution

If you're going the dedicated server route, Ubuntu Server is hard to beat for beginners. It has excellent documentation, a huge community, and long-term support versions that stay stable for years. Here's why I recommend it:

  • Ubuntu Server 22.04 LTS: Rock-solid stability, supported until 2032
  • Minimal installation: No GUI overhead, perfect for servers
  • Extensive package repository: Almost everything you need is available
  • Great Docker support: Official Docker packages and documentation

Installing Ubuntu Server

The installation is straightforward, but here are some tips that aren't always obvious:

During Installation:

  • Enable OpenSSH server (you'll want to manage this remotely)
  • Don't install Docker during OS setup – we'll do it properly afterward
  • Set a static IP address if possible (makes accessing services much easier)
  • Create a user account with a strong password

Post-Installation Essentials:

# Update everything first sudo apt update && sudo apt upgrade -y # Install essential tools sudo apt install curl wget git htop nano ufw # Set up basic firewall sudo ufw enable sudo ufw allow ssh

Installing Docker on Ubuntu

Here's the official Docker installation method that actually works reliably:

# Remove any old Docker installations sudo apt remove docker docker-engine docker.io containerd runc # Install prerequisites sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release # Add Docker's official GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg # Add Docker repository echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Install Docker sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin # Add your user to the docker group (avoid sudo for docker commands) sudo usermod -aG docker $USER # Log out and back in for group changes to take effect

Test your installation:

docker --version docker compose version docker run hello-world

If that last command pulls and runs a container successfully, you're ready to go!

Path 2: Setting Up Docker on Windows 11 with WSL2

Enabling WSL2

Windows Subsystem for Linux version 2 is a game-changer for developers. It gives you a real Linux kernel running inside Windows with near-native performance.

Step 1: Enable Windows Features
Open PowerShell as Administrator and run:

# Enable WSL and Virtual Machine Platform dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart # Restart your computer

Step 2: Set WSL2 as Default
After restart, run:

wsl --set-default-version 2

Step 3: Install Ubuntu
Open Microsoft Store and install "Ubuntu 22.04 LTS". Launch it and complete the initial setup with a username and password.

Installing Docker Desktop

Download Docker Desktop from the official Docker website. During installation:

  • Make sure "Use WSL 2 instead of Hyper-V" is checked
  • Enable integration with your Ubuntu distribution

After installation, Docker Desktop will automatically configure WSL2 integration. You can verify everything works by opening your Ubuntu terminal and running:

docker --version docker compose version

Installing Portainer: Your Docker Management Interface

Portainer transforms Docker from a command-line tool into something you can manage through a beautiful web interface. It's perfect for beginners and incredibly powerful for advanced users.

Why Portainer Matters

Think of Portainer as your Docker control center. Instead of remembering complex docker commands, you get:

  • Visual container management (start, stop, view logs, access terminals)
  • Stack deployment with docker-compose files
  • Image management and registry integration
  • User management and access control
  • Resource usage monitoring

Installing Portainer

The installation is remarkably simple:

# Create a volume for Portainer data docker volume create portainer_data # Run Portainer docker run -d \ -p 8000:8000 \ -p 9443:9443 \ --name portainer \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data \ portainer/portainer-ce:latest

For Windows 11/WSL2 users: Run this command in your Ubuntu terminal, not Windows PowerShell.

First-Time Portainer Setup

  1. Open your browser and navigate to https://localhost:9443 (or https://your-server-ip:9443 for Linux servers)
  2. You'll see a security warning – click "Advanced" and "Proceed to localhost" (this is normal for local development)
  3. Create your admin account (make it secure – this controls your entire Docker environment)
  4. Choose "Docker" as your environment type
  5. Portainer will automatically connect to your local Docker instance
Pro Tip: Bookmark this URL! You'll be using Portainer constantly to manage your containers.

Installing Homepage: Your Service Dashboard

Homepage is a modern, customizable dashboard for all your self-hosted services. Instead of remembering different IP addresses and ports, you get a beautiful landing page with everything organized.

Why You Need a Dashboard

As your home lab grows, you'll have services running on different ports:

  • Portainer on port 9443
  • A media server on port 8096
  • A database interface on port 8080
  • Development tools on various other ports

Homepage solves this by giving you a single place to access everything, plus it looks professional enough to show off to friends and potential employers.

Installing Homepage

We'll use docker-compose for this, which makes configuration much easier:

# Create a directory for Homepage mkdir ~/homepage cd ~/homepage # Create the docker-compose.yml file nano docker-compose.yml

Paste this configuration:

version: '3.3' services: homepage: image: ghcr.io/gethomepage/homepage:latest container_name: homepage ports: - 3000:3000 volumes: - ./config:/app/config # Make sure your local config directory exists - /var/run/docker.sock:/var/run/docker.sock:ro # optional, for docker integrations restart: unless-stopped

For Windows 11/WSL2 users: Replace the docker.sock line with:

- //var/run/docker.sock:/var/run/docker.sock:ro

First-Time Homepage Configuration

# Create the config directory mkdir config # Start Homepage docker compose up -d # Check that it's running docker compose logs

Visit http://localhost:3000 (or http://your-server-ip:3000) and you should see Homepage running!

Basic Homepage Configuration

Homepage uses YAML files for configuration. Let's create a basic setup:

# Create the main configuration file nano config/settings.yaml

Add this basic configuration:

title: My Home Lab theme: dark color: slate layout: - Developer Tools: style: row columns: 4 - Media & Files: style: row columns: 4 - System Management: style: row columns: 4

Now create your services file:

# Create services configuration nano config/services.yaml

Add your first services:

- Developer Tools: - Portainer: href: https://localhost:9443 description: Docker container management icon: portainer.png - System Management: - Homepage: href: http://localhost:3000 description: Service dashboard icon: homepage.png

Restart Homepage to see your changes:

docker compose restart

Essential Configuration Tips

Setting Up Proper Networking

For Linux Servers:

# Check your server's IP address ip addr show # Make sure Docker containers can communicate sudo ufw allow from 172.16.0.0/12 to any

For Windows 11/WSL2:
Your services will be accessible at localhost or 127.0.0.1 from Windows applications.

Managing Container Startup

Add restart policies to ensure your services start automatically:

# In your docker-compose.yml files restart: unless-stopped # Restart unless manually stopped # or restart: always # Always restart, even after manual stops

Backing Up Your Configuration

Create a simple backup script:

#!/bin/bash # backup-homelab.sh DATE=$(date +%Y%m%d_%H%M%S) mkdir -p ~/backups tar -czf ~/backups/homelab_backup_$DATE.tar.gz ~/homepage/config docker run --rm -v portainer_data:/data -v ~/backups:/backup alpine tar czf /backup/portainer_backup_$DATE.tar.gz -C /data .

Troubleshooting Common Issues

"Permission denied" errors

# Make sure your user is in the docker group groups $USER # If docker isn't listed, run: sudo usermod -aG docker $USER # Then log out and back in

Containers won't start

# Check container logs docker logs container_name # or in Portainer, click on the container and view logs

Can't access services from other devices

# Check if ports are actually listening netstat -tlnp | grep :9443 # Make sure your firewall allows the ports sudo ufw allow 9443

WSL2 performance issues

  • Ensure Docker Desktop is using WSL2 backend
  • Allocate sufficient RAM to WSL2 in Docker Desktop settings
  • Keep your files in the Linux filesystem (/home/user/) rather than Windows (/mnt/c/)

What's Next

At this point, you should have:

  • ✅ Docker installed and running smoothly
  • ✅ Portainer providing a web interface for container management
  • ✅ Homepage giving you a dashboard to organize your services
  • ✅ Basic understanding of docker-compose for multi-container applications

You're now ready to start adding real services to your home lab! In our next post, we'll dive into setting up a private search engine with SearXNG, running AI models locally with Ollama, and creating a ChatGPT-like interface with Open WebUI. We'll also add Apache Tika for document processing – setting the stage for some seriously impressive capabilities.

The foundation you've built today will support everything we add going forward. Docker's consistency means that whether you're running on an old laptop with Ubuntu or your main Windows 11 machine, the container configurations will work exactly the same way.

Quick Reference Commands

Essential Docker Commands:

docker ps # List running containers docker ps -a # List all containers docker logs container_name # View container logs docker exec -it container_name /bin/bash # Access container terminal

Docker Compose Commands:

docker compose up -d # Start services in background docker compose down # Stop and remove containers docker compose restart # Restart all services docker compose logs -f # Follow logs in real-time

System Maintenance:

docker system prune # Clean up unused containers, networks, images docker volume prune # Remove unused volumes (be careful!)

Ready to add some serious functionality to your home lab? Next week, we'll set up private search, local AI models, and document processing. The real fun is just getting started!

Questions or issues with the setup? Drop them in the comments – I've probably run into the same problems and can help you troubleshoot.

No comments:

Post a Comment

What do you think? (Comments are moderated and spam will be removed)