Setting Up TrueNAS Before Using Docker Stacks
Before you use this Docker stacks, make sure you have completed the following steps to properly configure TrueNAS:
[ Click to Expand ]- Step 1: Install TrueNAS Scale - Follow the official instructions from the TrueNAS website to install it on your hardware.
- Step 2: Extend Session Timeout - Increase the session timeout duration to prevent TrueNAS from logging you out prematurely:
- Navigate to "System > Advanced Settings > Access" in the TrueNAS interface.
- Click "Configure".
- Change the "Session Timeout" default value from "300" to: # This increases the session timeout from '5 minutes' to 1 hour *
- Click "Save".
3600
* For extra security, revert the session timeout back to 300 seconds after completing the configuration process!
- Step 3: Configure Console - Ensure that access to your TrueNAS console requires a username and password:
- Navigate to "System > Advanced Settings > Console" in the TrueNAS interface.
- Click "Configure".
- Uncheck "Show Text Console without Password Prompt".
- Click "Save".
- Step 4: Configure Location - Ensure that your regional settings are properly configured:
- Navigate to "System > General Settings > Location" in the TrueNAS interface.
- Click "Settings".
- Change the default settings to match your regional settings and formats.
- Click "Save".
- If needed, change the date/time settings in your TrueNAS system's BIOS to match your local date/time. # Correct date/time is crucial for logs and network services to work properly
- Step 5: Configure Network - Ensure that your network settings are properly configured:
- Navigate to "Network > Interfaces" in the TrueNAS interface.
- Click on the "Edit" button of your network interface to access the interface settings.
- Uncheck "DHCP".
- Uncheck "Autoconfigure IPv6".
- Set the "MTU" to:
- Set your TrueNAS IP address in the "Aliases" section, in most cases:
- Click "Save".
- Click on "Test Changes" and confirm.
- Access the IP address you set up for TrueNAS and login again to confirm the changes, in most cases:
- Click on "Go To Network Settings", followed by "Save Changes" and "Save" to confirm.
- Navigate to "Network > Interfaces" in the TrueNAS interface.
- Click on the "Edit" button of your network interface to access the interface settings.
- Delete your TrueNAS IP address from the "Aliases" section.
- Click "Save". # Don't click on the 'Test Changes' button
- Click on the "Add" button to add a new network interface.
- Select "Bridge" from the "Type" dropdown menu to create a virtual Switch.
- Type "br0" in the "Name" field.
- Type "vSwitch" in the "Description" field.
- Uncheck "DHCP".
- Uncheck "Autoconfigure IPv6".
- Select your network interface (e.g.: eno1, eth0, etc...) from the "Bridge Members" dropdown menu.
- Set the "MTU" to:
- Set your TrueNAS IP address in the "Aliases" section, in most cases:
- Click "Save".
- Click on "Test Changes" and confirm.
- Click on "Save Changes", followed by "Save" to confirm.
- Navigate to "Network > Global Configuration > Settings" in the TrueNAS interface.
- Replace "local" in the "Domain" field with your Top Level Domain name (e.g.: example.com) if you own one.
- Add the following nameservers to the "DNS Servers":
- Add your router's IP address to the "Default Gateway", in most cases:
- Click "Save".
- Navigate to "System > General Settings > GUI > Settings" in the TrueNAS interface.
- Choose your TrueNAS IP address in "Web Interface IPv4 Address", in most cases:
- Change your TrueNAS HTTP port in "Web Interface HTTP Port" from 80 to:
- Change your TrueNAS HTTPS port in "Web Interface HTTPS Port" from 443 to:
- Check "Web Interface HTTP -> HTTPS Redirect".
- Check "Show Console Messages".
- Uncheck "Usage collection".
- Click "Save".
- Navigate to "System > Advanced Settings > Sysctl" in the TrueNAS interface.
- Add the following "Variable=Value" pairs: # Don't copy the '=' sign in between the Variables and their Values
- Your Sysctl should look like this: # Variables and Values have different fields
- Click "Save".
1500
192.168.1.1/24
https://192.168.1.1
1500
192.168.1.1/24
1.1.1.2
1.0.0.2
9.9.9.9
192.168.1.254
192.168.1.1
81
444
net.ipv6.conf.all.disable_ipv6=1
net.ipv4.ip_forward=1
Var Value Enabled Description net.ipv6.conf.all.disable_ipv6 1 Yes net.ipv4.ip_forward 1 Yes
- Step 6: Configure SSH (optional) - Configure SSH access for your "truenas_admin" account:
- Copy and paste the following command into your terminal (on your local computer):
- Press "Enter" to accept the default location:
- Enter a passphrase for extra security. # This will secure your private key
- Re-enter the same passphrase to confirm.
- Navigate to "Credentials > Users" in the TrueNAS web interface.
- Select your "truenas_admin" account.
- Click on the "Edit" button.
- Under "Upload SSH Key", click "Choose File" and select your public key file: # id_ed25519.pub
- Change the "Shell" to "bash".
- Click "Save".
- Navigate to "System > Services" in the TrueNAS web interface.
- Toggle the "SSH" service to "ON".
- Toggle the "Start Automatically" option to "ON" to run SSH at every boot.
- To access your TrueNAS system via SSH, copy and paste the following command into your terminal (on your local computer): # Replace '192.168.1.1' with your TrueNAS IP address
ssh-keygen -t ed25519
%USERPROFILE%\.ssh\id_ed25519 (Windows)
~/.ssh/id_ed25519 (macOS/Linux)
%USERPROFILE%\.ssh\id_ed25519.pub (Windows)
~/.ssh/id_ed25519.pub (macOS/Linux)
ssh [email protected]
- Step 7: Create ZFS Pools - You'll need to create at least one ZFS pool to store your System/Apps data:
- Navigate to "Storage" in the TrueNAS interface.
- Click on the "Create Pool" button near the top right.
- Type "tank" on the "Name" field. # This is the default name used in ZFS documentation and in this guide
- Check "Encryption" (optional). # You'll need to download and securely store your encryption key, losing it may result in 'PERMANENT DATA LOSS' *
- If encryption is enabled, confirm that "Encryption is for users storing sensitive data" and click "I Understand".
- Click "Next".
- Select your pool "Layout". # Use at least a Mirror configuration and prioritize low-latency, high-performance storage (e.g.: Optane, NVMe) for your System/Apps pool
- Choose the appropriate "Disk Size".
- Check "Treat Disk Size as Minimun".
- Set the "Width". # Use at least two disks per VDEV to ensure redundancy
- Set the "Number of VDEVs". # More VDEVs generally result in higher IOPS, which are especially important for your System/Apps pool
- Click "Save And Go To Review".
- Click on the "Create Pool" button to create your System/Apps pool.
- Confirm that "The contents of all added disks will be erased" and click "Continue".
- If needed, refer to the official TrueNAS documentation for detailed guidance on pool creation and best practices.
Sample Pool Setup (based on the reference system used for this guide):
System / Apps Name: tank Disks: 7 Optane Layout: 3 x Mirror + Spare
Media / Downloads Name: morpheus Disks: 2 HDD + 4 NVMe Layout: 1 x Mirror + SLOG (NVMe Mirror) + Metadata (NVMe Mirror)
Data / Shares Name: trinity Disks: 4 SSD Layout: 1 x RAIDZ1
Backups Name: neo Disks: 8 SSD Layout: 1 x RAIDZ2
* To download your Encryption Keys: Navigate to 'Datasets' in the TrueNAS interface, select each encrypted pool and click the 'Export Key' button in the 'ZFS Encryption' section!
- Step 8: Configure Apps' Pool - You'll need to configure your Apps' pool to store your Apps data:
- Navigate to "Apps > Configuration > Choose Pool" in the TrueNAS interface.
- Select your TrueNAS Apps' pool name from the list, in most cases:
- Click "Choose" to save.
tank
- Step 9: Install NVIDIA Drivers (optional) - If you have a NVIDIA GPU make sure you install the NVIDIA drivers/runtime:
- Navigate to "Apps > Configuration > Settings" in the TrueNAS interface.
- Check "Install NVIDIA Drivers"
- Click "Save".
- Step 10: Configure S.M.A.R.T. Tests - Ensure that you create periodic S.M.A.R.T. tests of your Disks:
- Navigate to "Data Protection > Periodic S.M.A.R.T. Tests" in the TrueNAS interface.
- Click "Add".
- Check "All Disks".
- Select "SHORT" from the "Type" dropdown menu.
- Select "Weekly (0 0 * * sun) On Sundays at 00:00 (12:00 AM)" from the "Schedule" dropdown menu. # Or change it to meet your needs
- Click "Save".
- Step 11: Configure ZFS Snapshots - Ensure that you create periodic snapshots of your Apps' pool:
- Navigate to "Data Protection > Periodic Snapshot Tasks" in the TrueNAS interface.
- Click "Add".
- Select your TrueNAS Apps' pool name from the "Dataset" dropdown menu, in most cases:
- Check "Recursive".
- Uncheck "Allow Taking Empty Snapshots".
- Keep the "Schedule" settings at their default values. # Or change them to meet your needs
- Click "Save".
- In the future, set periodic snapshot tasks for your individual datasets instead.
tank
- Step 12: Configure ZFS Replication (optional) - If you have more than one pool, you can back up your Apps' pool to a different pool:
- Navigate to "System > Shell" in the TrueNAS interface.
- Type "cli" and press Enter.
- Copy and paste the following command into the TrueNAS CLI: # Replace 'backups' with your Backups' pool name
- Type "exit" and press Enter.
- Navigate to "Data Protection > Replication Tasks" in the TrueNAS interface.
- Click "Add".
- Select your source location: # Replace 'tank' with your Apps' pool name
- Select your target location: # Replace 'backups' with your Backups' pool name
- Check "Recursive".
- Type "tank_backup" in the "Task Name" field.
- Click "Next".
- Keep the "Schedule" settings at their default values. # Or change them to meet your needs
- Click "Save".
- Click on the "Edit" button of your new replication task.
- Search for "Destination Dataset Read-only Policy" and change it from "SET" to: # This will preserve your Apps' pool permissions
- Click "Save".
- In the future, set replication tasks for your individual datasets instead.
storage dataset create name=backups/tank share_type=GENERIC
Source Location: On this System
Source: /mnt/tank
Target Location: On this System
Target: /mnt/backups/tank
IGNORE
- Step 13: Create Datasets - You'll need to create datasets within your ZFS pools to organize and manage your data:
- Navigate to "System > Shell" in the TrueNAS interface.
- Type "cli" and press Enter.
- Copy and paste the following commands into the TrueNAS CLI: # Replace 'tank' with your Apps' pool name
- Copy and paste the following commands into the TrueNAS CLI: # Replace 'tank' with your Media/Downloads' pool name (it can be your Apps' pool)
- Copy and paste the following commands into the TrueNAS CLI: # Replace 'tank' with your Data/Shares' pool name (it can be your Apps' pool)
- Type "exit" and press Enter.
- Navigate to "Datasets" in the TrueNAS interface.
- Expand your Apps' pool tree and click on the "docker" dataset to select it.
- Navigate to "Permissions > Edit" to access the ACL Editor.
- Set the following "Access Control List": # This is the default ACL for Apps (which is applied when you set 'share_type=APPS' during dataset creation)
- Check "Apply permissions recursively" and confirm.
- Check "Apply permissions to child datasets".
- Click "Save Access Control List".
- Repeat steps 7-13 for the "downloads" and "media" datasets (instead off the "docker" dataset), which are located at the root of your Media/Downloads' pool.
- Repeat steps 7-13 for the "data" dataset (instead off the "docker" dataset), which is located at the root of your Data/Shares' pool.
storage dataset create name=tank/docker share_type=APPS
storage dataset create name=tank/docker/dockge share_type=SMB
storage dataset create name=tank/docker/dockge/stacks share_type=SMB
storage dataset create name=tank/docker/dockge/data share_type=SMB
storage dataset create name=tank/docker/notifications share_type=SMB
storage dataset create name=tank/docker/notifications/diun share_type=SMB
storage dataset create name=tank/docker/notifications/gotify share_type=SMB
storage dataset create name=tank/incus share_type=GENERIC
storage dataset create name=tank/downloads share_type=APPS
storage dataset create name=tank/media share_type=APPS
storage dataset create name=tank/media/audiobooks share_type=SMB
storage dataset create name=tank/media/books share_type=SMB
storage dataset create name=tank/media/movies share_type=SMB
storage dataset create name=tank/media/music share_type=SMB
storage dataset create name=tank/media/podcasts share_type=SMB
storage dataset create name=tank/media/tvseries share_type=SMB
storage dataset create name=tank/data share_type=APPS
storage dataset create name=tank/users share_type=SMB
owner@ - root Allow | Full Control group@ - root Allow | Modify Group - builtin_users Allow | Modify Group - builtin_administrators Allow | Full Control User - apps Allow | Modify
- Step 14: Create Docker Networks - You'll need to create the "proxy" and "home" networks to easily access your Docker services:
- Navigate to "System > Shell" in the TrueNAS interface.
- Copy and paste the following commands into the TrueNAS shell:
- If needed, replace the "home" network's subnet, ip-range and gateway to match your TrueNAS network's settings.
sudo docker network create --driver=bridge --subnet=172.17.0.0/24 --ip-range=172.17.0.0/24 --gateway=172.17.0.1 proxy
sudo docker network create --driver=macvlan --subnet=192.168.1.0/24 --ip-range=192.168.1.0/24 --gateway=192.168.1.254 -o parent=br0 home
- Step 15: Install Dockge - Use Dockge to manage all your Docker stacks. To install it:
- Navigate to "Apps > Discover Apps" in the TrueNAS interface.
- Search for "dockge" and click to install.
- Navigate to "Network Configuration" in the installation interface.
- Keep the default "WebUI Port":
- Change the "Certificate" to:
- Navigate to "Storage Configuration" in the installation interface.
- Choose the following type in "Dockge Stacks Storage":
- Insert the following path in "Host Path": # Replace 'tank' with your Apps' pool name
- Choose the following type in "Dockge Data Storage":
- Insert the following path in "Host Path": # Replace 'tank' with your Apps' pool name
- Navigate to "Labels Configuration" in the installation interface.
- Add the following "Key=Value" pairs: # Don't copy the '=' sign in between the Keys and their Values
- Make sure to set "dockge" in the "Containers" section of each label.
- Click "Install" and wait for the green "Running" status indicator.
- Click on the "Web UI" button in the "Application Info" section to open Dockge.
- Change the URL to "https://" and press Enter. # Add this page to your browser's bookmark bar
- Set your "Username" and "Password". # Confirm password
- Click "Create".
31014
'truenas_default' Certificate
Host Path (Path that already exists on the system)
/mnt/tank/docker/dockge/stacks
Host Path (Path that already exists on the system)
/mnt/tank/docker/dockge/data
diun.enable=true
tsdproxy.enable=true
tsdproxy.name=dockge
tsdproxy.scheme=https
tsdproxy.tlsvalidate=false
tsdproxy.container_port=31014
- Step 16: Install Gotify and DIUN - Use Gotify and DIUN to manage your notifications. To install them:
- Click on the "+ Compose" button on Dockge Web interface and type "notifications" on the "Stack Name" field.
- Click "Delete" on the "nginx" container.
- Copy the notifications stack Docker Compose:
- Paste the notifications stack Docker Compose where it says: # Replacing the default
- Copy the notifications stack .env file:
- Paste the notifications stack .env file where it says: # Replacing the default
- Edit the .env file to meet your TrueNAS set up if needed. # Ignore "TRUENAS_TOKEN" and "DIUN_TOKEN" for now
- Click "Deploy" to install.
- Click on the port "31015" in the "gotify" container to access Gotify.
- Type "admin" in "Username" and "Password" fields and click "Login". # Default
- Navigate to "ADMIN" in Gotify's Web interface, type a "New Password" for the default user and click on "CHANGE".
- Navigate to "APPS" in Gotify's Web interface and click on "CREATE APPLICATION" to add TrueNAS as an App.
- Type "TrueNAS" in the "Name" field and click "CREATE".
- Click on the button to show the token and copy the generated token.
- Go back to Dockge's interface and click "Edit" on the notifications stack.
- Paste the generated token into the .env file where it says:
- Go back to "APPS" in Gotify's Web interface and click on "CREATE APPLICATION" to add DIUN as an App.
- Type "DIUN" in the "Name" field and click "CREATE".
- Click on the button to show the token and copy the generated token.
- Go back to Dockge's interface and paste the generated token into the .env file where it says:
- Click "Deploy" to redeploy the notifications stack.
#################################################################################################### # name: NOTIFICATIONS #################################################################################################### services: #################################################################################################### # GOTIFY | URL: https://gotify.net #################################################################################################### gotify: container_name: gotify image: gotify/server environment: - TZ=${TZ:-Europe/Lisbon} volumes: - /mnt/${APPS_POOL:-tank}/docker/notifications/gotify:/app/data networks: proxy: ipv4_address: 172.17.0.48 ports: - 31015:80 labels: - diun.enable=true - tsdproxy.enable=true - tsdproxy.name=gotify - tsdproxy.container_port=31015 - tsdproxy.dash.visible=false - traefik.enable=true - traefik.docker.network=proxy - traefik.http.routers.gotify.entrypoints=websecure - traefik.http.routers.gotify.rule=Host(`gotify.${DOMAIN:-home.arpa}`) || Host(`gotify.ts.${DOMAIN:-home.arpa}`) - traefik.http.routers.gotify.tls=true - traefik.http.services.gotify.loadbalancer.server.port=80 #- traefik.http.routers.gotify.middlewares=tinyauth #- traefik.http.routers.gotify-ext.entrypoints=websecure-ext #- traefik.http.routers.gotify-ext.rule=Host(`gotify.${DOMAIN:-home.arpa}`) #- traefik.http.routers.gotify-ext.tls=true #- traefik.http.services.gotify-ext.loadbalancer.server.port=80 #- traefik.http.routers.gotify-ext.middlewares=tinyauth restart: unless-stopped #################################################################################################### # TRUENAS GOTIFY ADAPTER | URL: https://github.com/ZTube/truenas-gotify-adapter #################################################################################################### gotify-truenas-adapter: container_name: gotify-truenas-adapter image: ghcr.io/ztube/truenas-gotify-adapter:main environment: - GOTIFY_URL=http://172.17.0.48 - GOTIFY_TOKEN=${TRUENAS_TOKEN} network_mode: host labels: - diun.enable=true - tsdproxy.enable=false - traefik.enable=false restart: unless-stopped depends_on: gotify: condition: service_started #################################################################################################### # DOCKER IMAGE UPDATE NOTIFIER | URL: https://crazymax.dev/diun #################################################################################################### diun: container_name: diun image: crazymax/diun:latest command: serve environment: - TZ=${TZ:-Europe/Lisbon} - LOG_LEVEL=info - DIUN_WATCH_WORKERS=20 - DIUN_WATCH_SCHEDULE=0 */6 * * * - DIUN_WATCH_JITTER=30s - DIUN_WATCH_RUNONSTARTUP=true - DIUN_PROVIDERS_DOCKER=true - DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULT=true - DIUN_NOTIF_GOTIFY_ENDPOINT=http://172.17.0.48 - DIUN_NOTIF_GOTIFY_TOKEN=${DIUN_TOKEN} - DIUN_NOTIF_GOTIFY_PRIORITY=1 - DIUN_NOTIF_GOTIFY_TIMEOUT=10s volumes: - /var/run/docker.sock:/var/run/docker.sock - /mnt/${APPS_POOL:-tank}/docker/notifications/diun:/data network_mode: host labels: - diun.enable=true - tsdproxy.enable=false - traefik.enable=false restart: unless-stopped depends_on: gotify: condition: service_started #################################################################################################### # NETWORKS #################################################################################################### networks: proxy: external: true home: external: true #################################################################################################### # EOF - TrueNAS-Compose - URL: https://www.truenas-compose.com ####################################################################################################
version: "3.8" services: {} networks: {}
#################################################################################################### # .env - NOTIFICATIONS #################################################################################################### # GLOBAL: APPS_POOL=tank # Replace 'tank' with your Apps' pool name DOMAIN=home.arpa # Replace 'home.arpa' with your Top Level Domain name (e.g.: example.com) TZ=Europe/Lisbon # Replace 'Europe/Lisbon' with your local time zone PUID=568 # Default: 568 (Apps) PGID=568 # Default: 568 (Apps) #################################################################################################### # GOTIFY: TRUENAS_TOKEN=truenas_token # Replace 'truenas_token' with your TrueNAS token DIUN_TOKEN=diun_token # Replace 'diun_token' with your DIUN token #################################################################################################### # EOF - TrueNAS-Compose - URL: https://www.truenas-compose.com ####################################################################################################
# VARIABLE=value #comment
TRUENAS_TOKEN=truenas_token
DIUN_TOKEN=diun_token
- Step 17: Configure Alerts - You'll need to configure Gotify alerts to warn you of any issues with your TrueNAS system:
- Navigate to "System > Alert Settings" in the TrueNAS interface.
- Click on the "Add" button to add a new alert.
- Type "Gotify" in the "Name" field.
- Select "Slack" from the "Type" dropdown menu.
- Select "Info" from the "Level" dropdown menu.
- Copy and paste the following URL into the "Webhook URL" field:
- Click "Send Test Alert" to test the connection. # It will generate a test alert on your Gotify's dashboard
- Click "Save" to confirm.
http://localhost:31662
- Step 18: Save Configuration - Ensure that you back up your TrueNAS Scale configuration file: # Do this periodically
- Navigate to "System > General Settings" in the TrueNAS interface.
- Click on the "Manage Configuration" dropdown menu and select "Download File".
- Check "Export Password Secret Seed".
- Click "Save" to confirm.
- Step 19: Install OPNsense (optional) - If you have more than one network interface, you can install OPNsense firewall as an Instance: [ Click to Expand ]
Work in progress... please be patient! :)
Once these steps are completed, you'll be ready to use this Docker stacks on your TrueNAS Scale.
Choose a Docker Stack from the dropdown below to get the Docker Compose and .env File configurations, along with Installation Instructions for TrueNAS Scale.
Docker Compose
.env File
Installation Instructions for TrueNAS Scale
If you need help (or want to help), feel free to reach out on this thread on the Level1Techs' forum: TrueNAS-Compose