Basic Homeserver Docker Setup
Basic Homeserver Docker Setup
In this tutorial, we’ll walk through setting up a basic homeserver using Docker. We’ll cover the installation and configuration of several useful services, including Nextcloud, MariaDB, Redis, SearXNG, Nginx Proxy Manager, and Portainer.
Prerequisites
- A Linux-based system (e.g., Ubuntu, Debian)
- Docker and Docker Compose installed
- Basic knowledge of command-line operations
Step 1: Create the Dockerfile for Nextcloud with FFmpeg
This is required to have video thumbnails and playback support.
Create a file named nextcloud-ffmpeg
in your project directory with the following content:
FROM nextcloud:latest
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
This Dockerfile extends the official Nextcloud image and adds FFmpeg support.
Step 2: Create .env & Docker Compose Files
To separate sensitive information like passwords, create a .env
file in the same directory as your docker-compose.yaml
:
MYSQL_PASSWORD=your_secure_password
MYSQL_ROOT_PASSWORD=your_secure_root_password
Create a file named docker-compose.yaml
in your project directory with the following content:
version: '3.8'
services:
# IT Tools - Collection of useful IT tools
it-tools:
image: corentinth/it-tools:latest
container_name: itt
ports:
- "8081:80"
restart: unless-stopped
# MariaDB for Nextcloud
mariadb:
image: linuxserver/mariadb:latest
container_name: mariadb
environment:
- MYSQL_DATABASE=nc
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=username
- PGID=1000
- PUID=1000
- TZ=Europe/Berlin
ports:
- "3306:3306"
volumes:
- /appdata/mariadb/config:/config
restart: unless-stopped
# Nextcloud
nextcloud:
build:
context: .
dockerfile: nextcloud-ffmpeg
container_name: nextcloud
restart: unless-stopped
ports:
- "10081:80"
- "10444:443"
volumes:
- /appdata/nextcloud/var/www/html:/var/www/html
# Redis for Nextcloud caching
redis:
image: redis:latest
container_name: redis
ports:
- "6379:6379"
volumes:
- /appdata/redis/data:/data
- /appdata/redis/config:/usr/local/etc/redis
restart: unless-stopped
# SearXNG - Private search engine
searxng:
image: searxng/searxng:latest
container_name: searx
ports:
- "8085:8080"
environment:
- INSTANCE_NAME=SearXNG
- SEARXNG_SETTINGS_PATH=/etc/searxng/settings.yml
- UWSGI_SETTINGS_PATH=/etc/searxng/uwsgi.ini
- UWSGI_THREADS=4
- UWSGI_WORKERS=%k
volumes:
- /appdata/searxng:/etc/searxng
restart: unless-stopped
# Nginx Proxy Manager
app:
image: 'jc21/nginx-proxy-manager:latest'
container_name: nginx
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- /appdata/nginx-proxy-manager/data:/data
- /appdata/nginx-proxy-manager/letsencrypt:/etc/letsencrypt
# Portainer - Container management
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
ports:
- '8000:8000'
- '9443:9443'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /appdata/portainer:/data
Step 3: Create the Update Script
Create a file named dockerupdate.sh
with the following content:
#!/bin/bash
docker-compose pull
docker-compose down --remove-orphans
docker-compose build
docker-compose up --detach
Make the script executable:
chmod +x dockerupdate.sh
Step 6: Deploy the Services
Now, you can deploy all the services using Docker Compose:
docker-compose up -d
This command will download the necessary images, build the Nextcloud image with FFmpeg, and start all the containers in detached mode.
Step 7: Access the Services
After the containers are up and running, you can access the services using the following URLs:
- IT Tools:
http://your_server_ip:8081
- Nextcloud:
http://your_server_ip:10081
- SearXNG:
http://your_server_ip:8085
- Nginx Proxy Manager:
http://your_server_ip:81
- Portainer:
https://your_server_ip:9443
Replace your_server_ip
with the actual IP address or domain name of your server.
Step 8: Initial Configuration
Nextcloud: Access the Nextcloud URL and follow the setup wizard. Use the MariaDB database with the credentials specified in the
.env
file.Nginx Proxy Manager: Access the NPM URL and log in with the default credentials (Email:
admin@example.com
, Password:changeme
). Change these credentials immediately.Portainer: Access the Portainer URL and create your initial admin user.
SearXNG: The search engine should be ready to use. You may want to customize its settings by editing the
settings.yml
file in the/appdata/searxng
directory.Cockpit: If you followed my Debian guide, you can access your system using tailscale-ip:9090 and manage your server.
Step 9: Updating the Services
To update all services to their latest versions, run the update script:
./dockerupdate.sh
This script will pull the latest images, rebuild any custom images, and restart all containers.
Note: If you’re interested in creating a live website, please refer to my separate article on Nginx Manager for guidance.
Conclusion
You now have a basic homeserver setup with several useful services running in Docker containers. Remember to regularly update your services and keep your system secure by following best practices for server administration.