Installing Portainer on TrueNAS Community Edition with IP Binding
Prerequisites
Before we begin, make sure you’ve completed the TrueNAS post-installation setup. We’ll be building on those configurations, particularly the apps dataset we created.
Create a Dataset for Portainer
The first thing to do is create a new dataset for the app. In my case, I’ll create it inside the apps dataset we set up earlier.
- Go to Datasets ▸ click on the
appsdataset - Click Add Dataset
- Name:
portainer - Leave other settings as default ▸ Save
Add a Bridge Network Interface
Now for the interesting part - we’ll create a bridge network that allows us to bind Portainer to its own IP address.
Creating the Bridge
- Go to System ▸ Network ▸ Interfaces ▸ Add
- Type: Select
Bridge - Name:
br0(because we programmers like to start counting from 0) - Description:
Bridge Network for Apps(optional, but here we like to follow best practices)
br followed by a unique number.IP Address Configuration
Define Static IP Addresses is selected by default, so we’ll leave it that way.
Now we’ll add the IP addresses:
-
First IP Address: This must be the IP address already assigned to your TrueNAS interface
- For me, it’s
10.21.30.100/24
Side note: I like to use class A networks because they’re easier to remember and save some keystrokes
- For me, it’s
-
Second IP Address: This will be dedicated to Portainer
- I’ll use
10.21.30.101/24
Side note: I increment the last octet for simplicity and so I know this IP address is associated with this TrueNAS server (I have two servers).
- I’ll use
- Bridge Members: Select your existing network interface
- Leave the rest of the settings as default
- Click Save
Testing the Network Changes
You’ll see two buttons: Test Changes and Revert Changes.
- Click Test Changes
- If everything is configured correctly, the page will reload and you’ll be able to save the changes
- If something goes wrong, don’t worry - the changes are automatically reverted after 60 seconds
Configure TrueNAS GUI IP Binding
Now technically we could already bind the app to the .101 IP address, but there’s a caveat: we can’t use port 443 because the TrueNAS GUI now can be accessed on both IP addresses (.100 and .101).
To fix this, we need to bind the TrueNAS GUI to only one IP address:
- Go to System ▸ General Settings ▸ GUI
- Web Interface IP Address: Change to
10.21.30.100 - While we’re here, if you didn’t read my TrueNAS post-installation guide, you might want to configure:
- HTTP Redirect to HTTPS
- Show Console Messages
- And adjust your theme options
- Click Save
Now the TrueNAS GUI will only be accessible via the .100 IP address, freeing up port 443 on the .101 IP address for Portainer.
Install Portainer
We’re ready to install Portainer!
- Go to Apps ▸ Search for
Portainer▸ Click Install - The Community Edition image is set by default - this is fine
Network Configuration
- Publish port on the host for external access is selected by default - leave it that way
- Port: Change from the default port to
443 - Click Add next to Host IPs
- Select the
10.21.30.101IP address - Leave the rest as default
Storage Configuration
Under Storage Configuration:
- Portainer Storage: Change to
Host Path - Select the dataset you created earlier (
/mnt/tank/apps/portainer)
Resources Configuration
The last thing to configure is Resources Configuration if you want to adjust it. Personally, I think 2 CPUs and 4 GB of memory is too much for Portainer, so I’ll change the memory to 1 GB.
Click Install.
Access Portainer
Once the installation completes:
- Click the HTTPS button in the Application Info section
- This will open a new tab with the Portainer GUI
- You’ll need to accept the security warning as Portainer uses self-signed certificates - this is fine
Why This Setup is Awesome
What I really like about this setup is that we can access Portainer on its own IP address without having to type any port number. Since I use Bitwarden as my password manager, I use the Ctrl + Shift + L shortcut to automatically fill the username and password.
I don’t have to reach for the mouse, click on the Bitwarden extension, search for the Portainer credentials, and click autofill because I would have two accounts (TrueNAS and Portainer), and even more if I install more apps that bind to the TrueNAS IP address and only use a different port number.
Removing friction from my workflow is huge for me.