Docker & Portainer - Container Management Made Easy [Part 4 of 10]
Installing Docker and setting up a beautiful web UI for managing containers
![]()
![]()
![]()
![]()
Youāve got your server running and storage configured. Now itās time to install the magic that makes everything easy: Docker.
Docker lets you run applications in isolated containers. No more dependency hell, no more āit works on my machineā problems. Each service runs in its own container with everything it needs.
And Portainer? Thatās your web-based control panel for managing all those containers without memorizing commands.
What is Docker?
Docker is a platform for running applications in containers.
Think of containers like:
-
Lightweight virtual machines (but way more efficient)
-
Self-contained packages with everything an app needs
-
Isolated environments that donāt interfere with each other
Example:
-
Want to run a photo app? Pull a container.
-
Need a forum? Pull a container.
-
Want a wiki? Pull a container.
Each runs independently, uses minimal resources, and can be updated/removed without affecting others.
Why Docker for HomeLab?
Pros
-
Easy deployment - One command to install complex applications
-
Isolation - Apps donāt conflict with each other
-
Portability - Move containers between servers easily
-
Updates - Pull new image, restart container, done
-
Rollback - Something breaks? Revert to old version instantly
-
Resource efficient - Much lighter than VMs
-
Huge ecosystem - Thousands of pre-built images available
Cons
-
Learning curve - New concepts to understand
-
Networking complexity - Can be confusing at first
-
Storage management - Need to understand volumes
Perfect For
-
Web applications
-
Databases
-
Media servers
-
Monitoring tools
-
Pretty much everything weāre building in this series
What is Portainer?
Portainer is a web-based GUI for managing Docker.
Instead of typing commands like:
docker run -d --name myapp -p 8080:80 -v /data:/app/data myapp:latest
You click buttons in a web interface. Much easier for beginners (and faster for experts).
Features:
-
Visual container management
-
Template library for common apps
-
Stack deployment (docker-compose via web UI)
-
Resource monitoring
-
Log viewing
-
Network management
-
Volume management
And itās completely free (Community Edition).
Installing Docker
Step 1: Update System
# Update package lists and upgrade
sudo apt update && sudo apt upgrade -y
Step 2: Remove Old Docker Packages
If you have any old Docker installations, remove them:
# Remove conflicting packages
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
sudo apt-get remove $pkg
done
This ensures a clean installation.
Step 3: Install Dockerās Official Repository
Add Dockerās GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl -y
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Add Docker repository:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update package index:
sudo apt-get update
Step 4: Install Docker
Install Docker Engine and tools:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
This installs:
-
docker-ce- Docker Engine -
docker-ce-cli- Docker command-line tools -
containerd.io- Container runtime -
docker-buildx-plugin- Build tool -
docker-compose-plugin- Docker Compose (for multi-container apps)
Step 5: Verify Docker Installation
# Check Docker version
docker --version
# Test Docker with hello-world
sudo docker run hello-world
You should see a āHello from Docker!ā message. If so, Docker is working!
Step 6: Add Your User to Docker Group
This lets you run Docker without sudo:
# Add your user to docker group (replace 'admin' with your username)
sudo usermod -aG docker admin
# Log out and back in for changes to take effect
# Or run this to apply immediately:
newgrp docker
# Test without sudo
docker run hello-world
Important: Log out and back in (or reboot) for group changes to fully take effect.
Step 7: Enable Docker to Start on Boot
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
Now Docker will start automatically when your server boots.
Step 8: Verify Docker Compose
Docker Compose is included as a plugin:
docker compose version
You should see something like Docker Compose version v2.x.x.
Installing Portainer
Now letās install Portainer to manage Docker via web UI.
Step 1: Create Portainer Data Directory
Create directory on your RAID array:
# Create directory for Portainer data
sudo mkdir -p /mnt/storage/docker/portainer_data
# Set ownership (replace 'admin' with your username)
sudo chown -R admin:admin /mnt/storage/docker
Step 2: Create Portainer Network
# Create a Docker network for Portainer
docker network create portainer-network
This network will be used by Portainer and other services.
Step 3: Deploy Portainer Container
Run Portainer:
docker run -d \
--name portainer \
--restart unless-stopped \
-p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /mnt/storage/docker/portainer_data:/data \
--network portainer-network \
portainer/portainer-ce:latest
What this does:
-
-d- Run in background (detached) -
--name portainer- Name the container -
--restart unless-stopped- Auto-restart on boot -
-p 9443:9443- Expose web UI on port 9443 -
-v /var/run/docker.sock:/var/run/docker.sock- Access to Docker -
-v /mnt/storage/docker/portainer_data:/data- Persistent data on RAID -
--network portainer-network- Connect to network -
portainer/portainer-ce:latest- Use latest Community Edition
Step 4: Configure Firewall for Portainer
On your Ubuntu server (via SSH), allow access to Portainer from your local network:
# Allow Portainer web UI from LAN
# NOTE: Replace 192.168.1.0/24 with YOUR network range
sudo ufw allow from 192.168.1.0/24 to any port 9443 proto tcp comment 'Portainer from LAN'
# Check firewall status
sudo ufw status numbered
Step 5: Access Portainer Web UI
Open your web browser and go to:
https://192.168.1.100:9443
Replace 192.168.1.100 with your serverās IP address.
Youāll see a security warning because Portainer uses a self-signed SSL certificate. This is normal. Click āAdvancedā and proceed.
Step 6: Initial Portainer Setup
First-time setup:
- Create admin account
-
Username:
admin(or your choice) -
Password: Choose a strong password (12+ characters)
-
Click āCreate userā
- Connect to Docker
-
Select āGet Startedā
-
Portainer will auto-detect your local Docker environment
-
Click on ālocalā to manage your Docker host
Youāre in! You should see the Portainer dashboard.
Portainer Quick Tour
Dashboard
-
Shows containers, images, volumes, networks
-
Quick stats on resource usage
Containers
-
View all running/stopped containers
-
Start, stop, restart, remove containers
-
View logs
-
Access container console
-
Inspect container details
Images
-
View downloaded images
-
Pull new images from Docker Hub
-
Remove unused images
Stacks
-
Deploy multi-container applications
-
Use docker-compose files via web UI
-
Manage entire application stacks
Volumes
-
Manage persistent data storage
-
Create, remove, inspect volumes
Networks
-
Manage Docker networks
-
Create custom networks for container communication
Deploying Your First Container (Example)
Letās deploy a simple test container using Portainer:
Via Portainer Web UI:
-
Go to Containers ā Add container
-
Name:
nginx-test -
Image:
nginx:latest -
Port mapping:
-
Host:
8080 -
Container:
80
- Click Deploy the container
Access it:
http://192.168.1.100:8080
You should see the nginx welcome page!
Remove it when done:
-
Go to Containers
-
Select
nginx-test -
Click Remove
Docker Compose with Portainer
Docker Compose lets you define multi-container applications in a YAML file.
Example: Create a stack in Portainer
-
Go to Stacks ā Add stack
-
Name:
test-stack -
Web editor: Paste this example:
version: '3.8'
services:
web:
image: nginx:latest
ports:
- "8080:80"
restart: unless-stopped
- Click Deploy the stack
Thatās it! The container is running. Much easier than command-line.
Monitoring with Portainer
View container logs:
-
Go to Containers
-
Click on container name
-
Click Logs
-
See real-time output
View resource usage:
-
Go to Containers
-
Click on container name
-
Click Stats
-
See CPU, memory, network usage
Access container console:
-
Go to Containers
-
Click on container name
-
Click Console
-
Select
/bin/bashor/bin/sh -
Click Connect
-
Youāre inside the container!
Best Practices
Container Data Storage
-
Always use volumes for persistent data
-
Store volumes on RAID array (
/mnt/storage/docker/) -
Never store important data inside containers (itās lost when container is removed)
Updates
-
Regularly update container images
-
Test updates before deploying to production
-
Keep Portainer itself updated
Security
-
Use strong passwords for Portainer
-
Only allow Portainer access from LAN (not internet)
-
Regularly review running containers
-
Remove unused images and containers
Backups
-
Backup
/mnt/storage/docker/directory -
Export Portainer stacks as YAML files
-
Document your container configurations
TL;DR
-
Docker runs applications in isolated containers
-
Portainer provides a web UI for managing Docker
-
Installation: Add Docker repo, install Docker, deploy Portainer container
-
Access:
https://your-server-ip:9443 -
Benefits: Easy deployment, isolation, portability, updates
-
Next: Weāll set up Nginx Proxy Manager for reverse proxy and SSL in Part 5
Your Turn
Whatās the first service youāre planning to run in Docker?
Have you used Docker before, or is this your first time?
Any questions about containers or Portainer?
Drop a comment below!
Navigation: ā Part 3 | Part 5 ā