WARNING: If you installed anything before May 1, 2025, you'll need to start over due to major changes in the dataset and network structure!
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 Community Edition - 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.
- Check "Enable Learning".
- 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
192.168.1.254
192.168.1.1
81
444
net.ipv6.conf.all.disable_ipv6=1
net.ipv4.ip_forward=1
NOTE: Always select "SYSCTL" from the "Type" dropdown menu.
Var Value Enabled Description net.ipv6.conf.all.disable_ipv6 1 Yes net.ipv4.ip_forward 1 Yes
- Step 6: 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 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. # Or watch this video: https://youtu.be/ykhaXo6m-04
Pool-level Encryption is Not Recommended TrueNAS 22.12.3 or later forces encryption for all child datasets and zvols within an encrypted root or parent dataset that are using the TrueNAS UI. However, datasets created outside of the UI, such as those created programmatically or manually via shell access, might not inherit encryption unless properly configured. For more granular control and awareness, we do not recommend users configure pool-level encryption of the root dataset. Instead, create an unencrypted pool and populate it with encrypted or unencrypted child datasets, as needed. Source: https://www.truenas.com/docs/scale/scaleuireference/storage/poolcreatewizardscreens/#pool-creation-wizard
* 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!
Sample Pool Setup (based on the reference system used for this guide):
Boot Name: boot-pool Disks: 2 SSD Layout: 1 x Mirror
System / Apps Name: tank Disks: 7 Optane Layout: 3 x Mirror + Spare
Media / Downloads Name: morpheus Disks: 2 HDD + 2 NVMe Layout: 1 x Mirror + Metadata/Small Blocks (NVMe Mirror)
Data / Games Name: trinity Disks: 4 SSD + 2 NVMe Layout: 1 x RAIDZ1 + Metadata/Small Blocks (NVMe Mirror)
Backups Name: neo Disks: 8 SSD Layout: 1 x RAIDZ2
- Step 7: Configure Auto TRIM (optional) - Enable Auto TRIM on NVMe/SSD pools to optimize performance and extend the lifespan of your drives: # Optane and HDDs do not use the TRIM command
- Navigate to "Storage" in the TrueNAS interface.
- Click "Edit Auto TRIM" on the "ZFS Health" widget of your NVMe/SSD pool.
- Check "Auto TRIM".
- Click "Save".
- Repeat steps 2-4 for each NVMe/SSD pool in your system.
WARNING: Some older or lower-quality SSD firmware may mishandle TRIM commands, potentially leading to data loss!
- 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, configure periodic snapshot tasks on the datasets associated with your Docker volumes instead.
tank
WARNING: Deleting data from your pools won't free up space unless you also delete the associated ZFS snapshots!
- 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, configure replication tasks on the datasets associated with your Docker volumes instead.
storage dataset create name=backups/tank share_type=APPS
Source Location: On this System
Source: /mnt/tank
Target Location: On this System
Target: /mnt/backups/tank
IGNORE
- Step 13: Create ZFS 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/Games' pool name (it can be your Apps' pool)
- Type "exit" and press Enter.
storage dataset create name=tank/docker share_type=APPS
storage dataset create name=tank/docker/dockge share_type=APPS
storage dataset create name=tank/docker/dockge/stacks share_type=APPS
storage dataset create name=tank/docker/dockge/data share_type=APPS
storage dataset create name=tank/docker/notifications share_type=APPS
storage dataset create name=tank/docker/notifications/diun share_type=APPS
storage dataset create name=tank/docker/notifications/gotify share_type=APPS
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=APPS
storage dataset create name=tank/media/books share_type=APPS
storage dataset create name=tank/media/movies share_type=APPS
storage dataset create name=tank/media/music share_type=APPS
storage dataset create name=tank/media/podcasts share_type=APPS
storage dataset create name=tank/media/tvseries share_type=APPS
storage dataset create name=tank/data share_type=APPS
storage dataset create name=tank/games share_type=APPS
storage dataset create name=tank/games/eggs share_type=APPS
storage dataset create name=tank/games/installers share_type=APPS
storage dataset create name=tank/games/roms share_type=APPS
storage dataset create name=tank/users share_type=SMB
- Step 14: Configure ZFS Record Sizes - Ensure that the record sizes are optimized for each dataset based on its specific workload: # Adjusting the 'recordsize' helps improve performance
- Navigate to "System > Shell" in the TrueNAS interface.
- Copy and paste the following commands into the TrueNAS shell: # Replace 'tank' with your Apps' pool name
- Copy and paste the following commands into the TrueNAS shell: # Replace 'tank' with your Media/Downloads' pool name
- Copy and paste the following commands into the TrueNAS shell: # Replace 'tank' with your Data/Games' pool name
- If needed, refer to the official OpenZFS documentation for detailed guidance on workload tuning. # https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Workload%20Tuning.html
sudo zfs set recordsize=16K tank/docker
sudo zfs set recordsize=16K tank/incus
sudo zfs set recordsize=16K tank/downloads
sudo zfs set recordsize=1M tank/media
sudo zfs set recordsize=1M tank/data
sudo zfs set recordsize=1M tank/games
sudo zfs set recordsize=1M tank/users
- Step 15: Configure Permissions - Ensure that the permissions are configured to grant access to your ZFS datasets:
- 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 1-7 for the "media" and "downloads" datasets (instead of the "docker" dataset), which are located at the root of your Media/Downloads' pool.
- Repeat steps 1-7 for the "data" and "games" datasets (instead of the "docker" dataset), which are located at the root of your Data/Games' pool.
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 16: Configure Users - You'll need to create a user account to access and manage your TrueNAS system:
- Copy and paste the following command into your terminal (on your local computer): # Ed25519 is a public-key signature system, more secure than RSA
- 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.
- Click on the "Add" button.
- Type your username on the "Full Name" and "Username" fields.
- Type your secure password on the "Password" and "Confirm Password" fields.
- Type your valid email address on the "Email" field. # It will be used to send you alerts
- Type "builtin_administrators" on the "Auxiliary Groups" field.
- Type "/mnt/tank/users" on the "Home Directory" field. # Replace 'tank' with your Data/Games' pool name
- Check "Create Home Directory".
- Under "Upload SSH Key", click "Choose File" and select your public key file: # id_ed25519.pub
- Select "bash" from the "Shell" dropdown menu.
- Check "Allow all sudo commands".
- Check "SMB User".
- Click "Save".
- Log out, then log back in using your new "Username" and "Password".
- Select your "truenas_admin" account.
- Click on the "Edit" button.
- Check "Lock User".
- Click "Save".
- Navigate to "System > General Settings > Email" in the TrueNAS interface.
- Click on the "Settings" button.
- Select "GMail OAuth" from the "Send Mail Method" options. # Or choose another method ('Outlook OAuth' for Microsoft accounts or 'SMTP' for other email providers) and ignore steps 26-27
- Click "Log in to Gmail".
- Proceed to set up your Oauth credentials.
- Click "Send Test Mail" to test the connection. # It will generate a test message on your email inbox
- Click "Save".
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)
NOTE: To configure SMTP with your preferred email provider, refer to their official documentation for setup instructions.
- Step 17: Configure SSH (optional) - Configure SSH access for your user account:
- Navigate to "System > Services" in the TrueNAS web interface.
- Click on the "Edit" button of the "SSH" service.
- Uncheck "Allow Password Authentication".
- Click on the "Advaced Settings" button.
- Select "br0" from the "Bind Interfaces" dropdown menu.
- Uncheck "None" and "AES128-CBC" from the "Weak Ciphers" dropdown menu.
- Click "Save".
- Toggle the "SSH" service to "ON".
- Toggle the "Start Automatically" option to "ON" to run SSH at every boot.
- Copy and paste the following command into your terminal (on your local computer): # Replace 'user' with your username and '192.168.1.1' with your TrueNAS IP address
ssh [email protected]
- Step 18: Create Docker Networks - You'll need to create the "dns", "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, aux-address and gateway to match your TrueNAS network's settings. # You'll need to keep the CIDR '/28' for a total of 16 hosts (e.g.: 192.168.1.48 - 192.168.1.63)
sudo docker network create --driver=bridge --subnet=172.17.0.0/24 --ip-range=172.17.0.0/24 --gateway=172.17.0.1 dns
sudo docker network create --driver=bridge --subnet=172.18.0.0/24 --ip-range=172.18.0.0/24 --gateway=172.18.0.1 proxy
sudo docker network create --driver=macvlan --subnet=192.168.1.0/24 --ip-range=192.168.1.48/28 --aux-address 'host=192.168.1.63' --gateway=192.168.1.254 -o parent=br0 home
- Step 19: Create Host Macvlan Network - You'll need to create the "home-shim" network to allow access to your "home" network from your host:
- Navigate to "System > Advanced Settings > Init/Shutdown Scripts" in the TrueNAS interface.
- Click "Add" to create a script that sets the "home-shim" network.
- Type "Host Macvlan" in the "Description" field.
- Select "Command" from the "Type" dropdown menu.
- Copy and paste the following command into the "Command" field:
- If needed, replace "192.168.1.48/28" with the ip-range of your "home" network and "192.168.1.63/32" with the aux-address for your host macvlan bridge.
- Select "Pre Init" from the "When" dropdown menu.
- Click "Save".
ip link add home-shim link br0 type macvlan mode bridge; ip addr add 192.168.1.63/32 dev home-shim; ip link set home-shim up; ip route add 192.168.1.48/28 dev home-shim
- Step 20: 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
- Step 21: 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:latest environment: - TZ=${TZ:-Europe/Lisbon} volumes: - /mnt/${APPS_POOL:-tank}/docker/notifications/gotify:/app/data networks: proxy: ipv4_address: 172.18.0.5 dns: ipv4_address: 172.17.0.5 ports: - 31015:80 dns: - 172.17.0.2 labels: - diun.enable=true - tsdproxy.enable=true - tsdproxy.name=gotify - 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=cloudflared #- 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.5 - 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_healthy #################################################################################################### # 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.5 - 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_healthy #################################################################################################### # NETWORKS #################################################################################################### networks: home: external: true proxy: external: true dns: 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 MEDIA_POOL=tank # Replace 'tank' with your Media/Downloads' pool name DATA_POOL=tank # Replace 'tank' with your Data/Games' 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 22: Install Gotify APP (Android only) - You'll need to install the Gotify app to get notifications:
- Download and install the latest Gotify app. # https://play.google.com/store/apps/details?id=com.github.gotify
- Type your "Gotify URL", in most cases: # Replace '192.168.1.1' with your TrueNAS IP address
- Click "Check URL".
- Ignore the warning saying "Using HTTP is insecure" and click "I Understand".
- Type "admin" in the "Username" field and your new password in the "Password" field.
- Click "Login".
- Choose a name for your session and click "Create".
- Enable notifications on your Android device.
http://192.168.1.1:31015
- Step 23: 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. # This will show you all syslog alerts, adjust the level as needed
- 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 (and a notification on your Android device)
- Click "Save" to confirm.
http://localhost:31662
- Step 24: Disable CPU Power Savings (optional) - Ensure that your CPU latency is minimal: # Reduces latency but increases power consumption
- Navigate to "System > Advanced Settings > Init/Shutdown Scripts" in the TrueNAS interface.
- Click "Add" to create a script that sets the CPU governor to "performance".
- Type "CPU governor" in the "Description" field.
- Select "Command" from the "Type" dropdown menu.
- Copy and paste the following command into the "Command" field:
- Select "Post Init" from the "When" dropdown menu.
- Click "Save".
- Click "Add" again to create a second script to disable the "C2" idle state.
- Type "CPU idle-states" in the "Description" field.
- Select "Command" from the "Type" dropdown menu.
- Copy and paste the following command into the "Command" field:
- Select "Post Init" from the "When" dropdown menu.
- Click "Save".
cpupower frequency-set -g performance
cpupower -c all idle-set -d 2
- Step 25: Disable PCIe Power Savings (optional) - Ensure that your high-performance storage (e.g.: Optane, NVMe) latency is minimal: # Reduces latency but increases power consumption
- Navigate to "System > Shell" in the TrueNAS interface.
- Copy and paste the following command into the TrueNAS SHELL:
midclt call system.advanced.update '{"kernel_extra_options": "nvme_core.default_ps_max_latency_us=0 pcie_aspm=off pci=noaer"}'
- Step 26: Offload RCU Callbacks (optional) - Offload RCU (Read-Copy-Update) callbacks from CPU cores to kernel threads: # Reduces latency and improves performance, especially on high-core-count systems
- Navigate to "System > Shell" in the TrueNAS interface.
- Copy and paste the following command into the TrueNAS SHELL: # Replace '63' with the number of logical CPU cores in your system minus 1 (e.g.: 64 threads - 1 = 63)
- If needed, copy and paste the following command into the TrueNAS SHELL to find the number of logical CPU cores in your system:
midclt call system.advanced.update '{"kernel_extra_options": "rcu_nocbs=0-63"}'
WARNING: If you previously configured Step 24, combine those options with these in a single command to avoid overwriting settings!
lscpu | grep '^CPU(s):'
- Step 27: Tune NVMe Driver (optional) - Ensure that the NVMe driver is optimized for your high-performance storage (e.g.: Optane, NVMe): # Improves NVMe performance by optimizing queue usage
- Navigate to "System > Shell" in the TrueNAS interface.
- Copy and paste the following command into the TrueNAS SHELL: # Choose only the configuration that matches your NVMe hardware layout
- Optane-only
midclt call system.advanced.update '{"kernel_extra_options": "nvme.poll_queues=2 nvme.write_queues=2 nvme.io_queue_depth=16 nvme.use_threaded_interrupts=1 nvme.max_host_mem_size_mb=512"}'
- Optane + NAND
midclt call system.advanced.update '{"kernel_extra_options": "nvme.poll_queues=2 nvme.write_queues=2 nvme.io_queue_depth=64 nvme.use_threaded_interrupts=1 nvme.max_host_mem_size_mb=512"}'
- NAND-only # Replace '8' with the number of physical CPU cores in your system divided by 4 (e.g.: 32 cores / 4 = 8) in 'nvme.poll_queues' and 'nvme.write_queues'
midclt call system.advanced.update '{"kernel_extra_options": "nvme.poll_queues=8 nvme.write_queues=8 nvme.io_queue_depth=256 nvme.use_threaded_interrupts=1 nvme.max_host_mem_size_mb=512"}'
WARNING: If you previously configured Step 24 and/or Step 25, combine those options with these in a single command to avoid overwriting settings!
lscpu | grep 'Core(s) per socket'
- Navigate to "System > Shell" in the TrueNAS interface.
- Copy and paste the following command into the TrueNAS SHELL: # Choose only the configuration that matches your storage pool layout
- NVMe-only pools # Work in progress... please be patient! :)
midclt call system.advanced.update '{"kernel_extra_options": "zfs.metaslab_lba_weighting_enabled=0"}'
- NVMe pools + SSD pools # Work in progress... please be patient! :)
midclt call system.advanced.update '{"kernel_extra_options": "zfs.metaslab_lba_weighting_enabled=0"}'
- NVMe pools + SSD pools + HDD pools # Work in progress... please be patient! :)
midclt call system.advanced.update '{"kernel_extra_options": ""}'
- NVMe pools + HDD pools # Work in progress... please be patient! :)
midclt call system.advanced.update '{"kernel_extra_options": ""}'
- If needed, refer to the official OpenZFS documentation for detailed guidance on module parameters. # https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Module%20Parameters.html
WARNING: If you previously configured Step 24 and/or Step 25 and/or Step 26, combine those options with these in a single command to avoid overwriting settings!
- 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.
#################################################################################################### # install - OPNsense #################################################################################################### 1 - Download and extract the latest OPNsense "dvd" image. # https://opnsense.org/download 2 - Set up your ISP router in "bridge" mode (usually on port number 4). # RTFM 3 - Navigate to "Network > Interfaces" in the TrueNAS interface. 4 - Click on the "Edit" button of the network interface you'll use to connect to the internet (WAN). 5 - Uncheck "DHCP". 6 - Uncheck "Autoconfigure IPv6". 7 - Set the "MTU" to "1500". 8 - Click "Save". # Don't click on the 'Test Changes' button 9 - Click on the "Add" button to add a new network interface. 10 - Select "Bridge" from the "Type" dropdown menu to create a virtual Switch. 11 - Type "br1" in the "Name" field. 12 - Type "vSwitch" in the "Description" field. 13 - Uncheck "DHCP". 14 - Uncheck "Autoconfigure IPv6". 15 - Select your network interface (e.g.: eno2, eth1, etc...) from the "Bridge Members" dropdown menu. 16 - Check "Enable Learning". 17 - Set the "MTU" to "1500". 18 - Click "Save". 19 - Click on "Test Changes" and confirm. 20 - Click on "Save Changes", followed by "Save" to confirm. 21 - Navigate to "Instances" in the TrueNAS interface. 22 - Select "Global Settings" from the "Configuration" dropdown menu. 23 - Select "tank" from the "Pool" dropdown menu. # Replace 'tank' with your Apps' pool name 24 - Select "br0" from the "Bridge" dropdown menu. 25 - Click "Save". 26 - Click "Create New Instance". 27 - Type "opnsense" in the "Name" field. 28 - Choose "VM" from the "Virtualization Method" menu. 29 - Choose "Upload ISO, import a zvol or use another volume" from the "VM Image Options". 30 - Click "Select Volume", followed by "Upload ISO" and select OPNsense ISO image. 31 - Wait for the download to finish and click "Select". 32 - Type "4" in the "CPU Configuration" field. # Or set it to your preference 33 - Type "8 GiB" in the "Memory Size" field. # Or set it to your preference 34 - Click "Add" in the "Disks" section. 35 - Click "Select Volume", followed by "Create Volume". 36 - Type "opnsense" in the "Name" field. 37 - Type "40 GiB" in the "Size" field. # Or set it to your preference 38 - Click "Create" 39 - Click "Select" on the new "opnsense" volume. 40 - Uncheck "Use default network settings". 41 - Check "br0" and "br1" from the "Bridged NICs" section. 42 - Check "Enable VNC". 43 - Click "Create". 44 - Open your VNC client and access: # Replace '192.168.1.1' with your TrueNAS IP address 192.168.1.1:5900 45 - Login using the user "installer" and password "opnsense". 46 - Select your "keymap" (keyboard layout). 47 - Select "Install (UFS)" and click "OK". 48 - Select "nda1 <QEMU NVMe Ctrl 7215 incusdisk0> (40GB)" and click "OK". 49 - Click "Yes" to create a recommended SWAP partition of 8GB. 50 - Click "Yes" to confirm that you're sure you want to destroy the current contents of the disk and wait for the installation to finish. 51 - Select "Complete Install" and click "OK". # Don't change the root password just yet 52 - Select "Halt now" and click "OK". 53 - Navigate to "Instances > opnsense > Disks" in the TrueNAS interface. # You may need to refresh the page to see the VM status as 'Stopped' 54 - Delete "OPNsense-25.1-dvd-amd64.iso (Virtio-SCSI)" and confirm to continue. 55 - Click on the "play" button to restart the VM. 56 - Reopen your VNC client and connect again to: # Replace '192.168.1.1' with your TrueNAS IP address 192.168.1.1:5900 57 - Login using the user "root" and password "opnsense". # Default 58 - Enter "2" to "Set interface IP address". 59 - Enter "1" to select the "LAN" interface. 60 - Enter "n" to disable DHCP. 61 - Type your OPNsense Web interface IP address, in most cases: # Replace '192.168.1.253' with OPNsense's IP address on your local network 192.168.1.253 62 - Type "24" as the subnet mask (255.255.255.0). 63 - Press "ENTER" to leave the gateway empty. 64 - Enter "n" to disable IPv6 via WAN tracking. 65 - Enter "n" to disable DHCP for IPv6. 66 - Press "ENTER" to leave IPv6 empty/disabled. 67 - Enter "n" to skip enabling the DHCP server. 68 - Enter "n" to keep the default web GUI protocol (HTTPS). 69 - Enter "n" to skip generating new certificates. 70 - Enter "n" to skip restoring default web GUI access. 71 - Open OPNsense's Web interface, in most cases: https://192.168.1.253 72 - Login using the user "root" and password "opnsense". 73 - Click "Next" to start the Wizard. 74 - Fill out the "General Information" section: # Replace 'home.arpa' with your Top Level Domain name (e.g.: example.com) Hostname: opnsense Domain: home.arpa Primary DNS Server: 1.1.1.2 Secondary DNS Server: 1.0.0.2 75 - Uncheck "Override DNS". 76 - Uncheck "Enable Resolver". 77 - Click "Next". 78 - Select you "Timezone". 79 - Click "Next". 80 - Ignore the "Configure WAN Interface" section and click "Next". 81 - Ignore the "Configure LAN Interface" section and click "Next". 82 - Change your "Root Password". 83 - Click "Next". 84 - Click "Reload" to apply the changes. 85 - Navigate to "System > Firmware > Status" in the OPNsense interface. 86 - Click "Check for updates". # Do this periodically 87 - Click "Close". 88 - Click "Update" to apply the updates and reboot. 89 - Login using the user "root" and the new password from step 81. 90 - Navigate to "Interfaces > LAN" in the OPNsense interface. 91 - Check "Lock" to prevent interface removal. 92 - Click "Save", followed by "Apply changes". 93 - Navigate to "Interfaces > WAN" in the OPNsense interface. 94 - Check "Lock" to prevent interface removal. 95 - Select "DHCP" from the "IPv4 Configuration Type" dropdown menu. 96 - Select "None" from the "IPv6 Configuration Type" dropdown menu. 97 - Click "Save", followed by "Apply changes". 98 - Navigate to "Interfaces > Settings" in the OPNsense interface. 99 - Uncheck "Allow IPv6". 100 - Click "Save". 101 - Navigate to "System > Settings > Administration" in the OPNsense interface. 102 - Select "LAN" from the "Listen Interfaces" and click "I know what I am doing" to confirm. 103 - Click "Save". 104 - Navigate to "System > Settings > General" in the OPNsense interface. 105 - Check "Prefer IPv4 over IPv6". 106 - Change the DNS servers "Use gateway" option from "None" to: # For both '1.1.1.2' and '1.0.0.2' WAN_GW - wan - 107 - Type "." in the "DNS search domain" field. 108 - Click "Save". 109 - Navigate to "System > Firmware > Plugins" in the OPNsense interface. 110 - Add the following plugins: os-clamav os-crowdsec os-tailscale 111 - Navigate to "Power > Reboot" in the OPNsense interface. 112 - Click "Yes" to reboot. 113 - Login using the user "root" and the new password from step 81. 114 - Navigate to "Lobby > Dashboard" in the OPNsense interface. 115 - Copy your "WAN_GW" IP address from the "Gateways" widget. 116 - Navigate to "Services > Intrusion Detection > Administration" in the OPNsense interface. 117 - Toggle the "advanced mode" option to "ON". 118 - Check "Enabled". 119 - Check "IPS mode". 120 - Check "Promiscuous mode". 121 - Select "Hyperscan" from the "Pattern matcher" dropdown menu. 122 - Paste the "WAN_GW" IP address from step 114 into the "Home networks" field. WARNING: You'll need to update this field everytime your public IP address changes! 123 - Click "Apply". 124 - Switch to the "Download" tab and select the following "Rulesets": # https://docs.opnsense.org/manual/ips.html#available-rulesets abuse.ch/Feodo Tracker abuse.ch/SSL Fingerprint Blacklist abuse.ch/SSL IP Blacklist abuse.ch/ThreatFox abuse.ch/URLhaus 125 - You may also select the "ET Open" ruleset (optional). # For guidance, visit the Emerging Threats Community at: https://community.emergingthreats.net 126 - Click "Enable selected". 127 - Click "Download & Update Rules". 128 - Navigate to "Services > ClamAV > Configuration" in the OPNsense interface. 129 - Check "Enable clamd service". 130 - Check "Enable freshclam service". 131 - Click "Save". 132 - Click "Download signatures" (on the top right corner of the page). 133 - Navigate to "System > Configuration > Backups" in the OPNsense interface. 134 - Click "Download Configuration". # Do this periodically 135 - Navigate to "System > Shell" in the TrueNAS interface. 136 - Copy and paste the following commands into the TrueNAS shell: sudo docker network rm home sudo docker network create --driver=macvlan --subnet=192.168.1.0/24 --ip-range=192.168.1.0/24 --gateway=192.168.1.253 -o parent=br0 home NOTE: If needed, replace the "home" network's subnet, ip-range and gateway (OPNsense) to match your TrueNAS network's settings! 137 - Navigate to "Network > Global Configuration > Settings" in the TrueNAS interface. 138 - Replace your router's IP address with your OPNsense IP address in the "Default Gateway" field, in most cases:
Once these steps are completed, you'll be ready to use this Docker stacks on your TrueNAS CE (Scale).
Choose a Docker Stack from the dropdown below to get the Docker Compose and .env File configurations, along with Installation Instructions for TrueNAS CE (Scale).
Docker Compose
.env File
Installation Instructions for TrueNAS CE (Scale)
If you need help (or want to help), feel free to reach out on this thread on the Level1Techs' forum: TrueNAS-Compose