🌱Docker HomeLab Notes
Published by Scott Kingery on
About
I have a Windows 11 mini PC that I am repurposing as a HomeLab to run Docker Containers on. I'll use this page to keep track of how things go.
Pre Ubuntu Server Install
- Make sure your PC is connected to a Wired port on the router
- Boot Windows and make sure the BIOS is up to date
- Make notes about the current Windows set up
- Go to Start and type About, copy all the details into a note you'll be able to find later
- Get the Windows Key by opening PowerShell as Administrator and type:
get key: powershell "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey"
- Get anything you may need later OFF of this PC because it's going away
- Make notes about the current Windows set up
- Download Ubuntu Server
- Get Ubuntu Server | Download | Ubuntu
- Burn it onto a USB flash drive with balenaEtcher - Flash OS images to SD cards & USB drives
- Boot to Windows, put the flash drive in an open USB slot and open a command prompt at Administrator
- type
shutdown /r /fw- This lets you boot back up into the BIOS so you can set it to boot from the flash drive
- Make your adjustments in the BIOS and save them
- type
Set up your network
You will help yourself out a lot if you have your network set up ahead of time. All routers are different so I can't tell you exactly where these setting are on yours but you'll want to have these set up before you move on.
- Now that you have Windows working on your server, reserve an IP address for it in you router's DHCP settings
- I set these up above my DHCP address range. That is, I have 192.168.1.2 through 200 availabe in DHCP and anything more than 200 is what I use for reservations like this one
- Set up home.arpa as your network domain name. Here are some resources about why I recommend this
Install Ubuntu Server
- When the computer boots, select the install option
- Choose full Ubuntu Server
- Use the full disk
- Note your username and password somewhere
- Install OpenSSH Server.
- Do not install extra server packages yet.
- Do not install Docker from Ubuntu’s optional package selection.
- Reboot when done
After the first boot:
sudo apt update
sudo apt full-upgrade
sudo reboot
- Connect to your new server via SSH (I use Putty on Windows) at its IP address
Basic Server Setup
- Set correct time zone
sudo timedatectl set-timezone America/Los_Angeles
timedatectl
- Here's how to find your time zone timedatectl Cheatsheet | Linuxize
- Ensure a few things are installed
sudo apt install curl ca-certificates git nano htop unattended-upgrades
- Enable automatic security updates:
sudo dpkg-reconfigure unattended-upgrades
Decide if you want to configure CPU Frequency Scaling
How to Configure CPU Frequency Scaling on Ubuntu Server
Install SAMBA
Samba lets you connect to your Linux shares from Windows. You may not be ready to actually share anything because you could add drives later but getting it installed will be helpful for the future. SAMBA isn't necessary for Docker so you could safely save this for later.
Install Docker
Use Docker’s official APT repository
sudo apt update
sudo apt install ca-certificates curl
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 the Docker repository:
sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
Install Docker and Compose:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
Test it:
sudo docker run hello-world
sudo docker compose version
sudo systemctl status docker
Create an Organized Application Structure
A consistent directory layout will make backup, troubleshooting, and migration much easier:
/srv/docker/
├── compose/
│ ├── dockge/
│ ├── uptime-kuma/
│ └── app-name/
├── appdata/
│ ├── dockge/
│ ├── uptime-kuma/
│ └── app-name/
└── backups/
Create the top-level directories:
sudo mkdir -p /srv/docker/{compose,appdata,backups}
sudo chown -R "$USER":"$USER" /srv/docker
Setup Dockge
Here is the Compose YAML
services:
dockge:
image: louislam/dockge:1
container_name: dockge
restart: unless-stopped
ports:
- 5001:5001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /srv/docker/compose:/opt/stacks
- /srv/docker/appdata/dockge:/app/data
environment:
- DOCKGE_STACKS_DIR=/opt/stacks
Setup Uptime Kuma
- Super useful because you can set it up to monitor other services on your network. For example, I have a pi-hole running on another computer and I can monitor it with Uptime Kuma.
services:
uptime-kuma:
image: louislam/uptime-kuma:2
container_name: uptime-kuma
restart: unless-stopped
ports:
- 3001:3001
volumes:
- /srv/docker/appdata/uptime-kuma:/app/data
I forgot my password once, don't do that! Here's how to reset it:
sudo docker exec -it <container name> bash
npm run reset-password
Monitoring Syncthing with Uptime Kuma
I have a central Syncthing server that all the PCs and my phone connect to. I want to be sure it is running.
- First you need to be sure you can access the GUI via a machine other than the on Syncthing is on. By default you access Syncthing at localhost:port. You can set the UI to be available from the LAN by following these instructions: The GUI Listen Address — Syncthing v2.0.0 documentation
- Then you can use Syncthing's built-in health REST API URL by simply putting http://yoursyncthing:port/rest/noauth/health (not YOUR Syncthing address and port)
