Install Trilium Notes Syncing Server and Desktop App
Trilium Notes is an impressively powerful note taking application with a lot of great add-on features that allow for chart drawing, mermaid charts, Latex style numerical formulas and much more.
It boasts a syncing server that is fairly easy to setup, as well as desktop applications for Linux, MacOS, and Windows. The web application available via the syncing server is a literal clone of the desktop application experience, and is responsive so it works well on all of your devices.
As you can see above, the webview on the mobile device is quite usable. In fact, I'm writing up this guide using Trilium Notes. I'll copy / paste it to my Show Notes afterward…and let you know how well it converts in the Show Notes at the end.
What You'll Need
- Sync Server
- Docker-CE and Docker-Compose installed
- (optional) NGinX Proxy Manager (for access from the internet)
- Client
- A Linux, MacOS, or Windows based PC
- Mobile
- A Web Browser
- Time
- About 15 minutes
Installation of Docker-CE and Docker-Compose (optionally NGinX Proxy Manager).
You can easily install Docker-CE, Docker-Compose, Portainer-CE, and NGinX Proxy manager by using this quick install script I created and maintain on Github. Just use the command:
wget
https://gitlab.com/bmcgonag/docker_installs/-/raw/main/install_docker_nproxyman.sh
To download the script to your desired host.
Change the permissions to make the script executable:
chmod +x ./install_docker_nproxyman.sh
and then run the script with the command:
./install_docker_nproxyman.sh
When run, the script will prompt you to select your host operating system, then will ask you which bits of software you want to install.
Simply enter 'y' for each thing you want to install.
In this case, that will be Docker-CE and Docker-Compose at a minimum, but you can also optionally install NGinX Proxy Manager if you don't already have and use another reverse proxy for your network.
At some point, you may be asked for your super user (sudo) password as well.
Allow the script to complete installation.
At this point, you might want to log out and back in, as this will allow you to use the docker
and docker-compose
commands without the need of sudo in front of them.
Install Trilium Notes Sync Server
I like to use a convention for keeping my docker containers organized. I create a parent level “docker” folder, then create an application / service folder for each application / service i want to run inside that parent folder. This allows me to run a simple backup where I just get all of the volumes and data and docker-compose files in one simple folder or zipped up file of folders under the parent “docker” folder level. If anything goes wrong I can bring the whole thing back up quickly, or even just pull out the application or service I may need.
For this reason I'll create a folder structure on my server like this:
mkdir -p docker/trilium_notes
The command above tells my system to use an existing “docker” directory if there is one, and if not, then create it, and the “trilium_notes” directory inside of it.
Next, we'll move into our new application directory with the command:
cd docker/trilium_notes
Now we need to create our docker-compose.yml file where we'll define our Trilium Notes sync server application. I use the nano text editor in the terminal, but if you're using a desktop environment, or prefer some other text editor, feel free to use your favorite.
nano docker-compose.yml
Next, copy the yaml code block below, and paste it into your fresh “docker-compose.yml” file. You can use CTRL+C to copy, and CTRL + Shift + V to paste into a terminal window.
version: '3.3'
services:
trilium:
ports:
- '8080:8080'
volumes:
- '~/trilium-data:/home/node/trilium-data'
image: 'zadam/trilium:0.56-latest'
The above code block will do a few things.
- It will create a service called “trilium”.
- It will forward your server's host port of 8080 to the container port of 8080. If you are already using the port 8080 on your host, you'll want to change the left side port number to some other port that is not in use on your host server. In my case I change it to 8295. So my port mapping looks like
- ‘8290:8080’
- It will setup a volume in the current directory (./docker/trilium_notes/) called “trilium-data”, and map that to the container location of “/home/node/trilium-data”. This is a good thing, as this is where our Trilium data is going to be stored, and it will be persisted between docker container updates, as well as being backed up if you setup backups of your “docker” parent folder.
When you've got the code block in your file, and you've made the port mapping change (if needed), you can save the file with CTRL + O, then press Enter to confirm. Take one last look and make sure everything looks ok. Remember, yaml code is space dependent, so make sure everything that is indented, is indented 2 spaces past it's parent item. Formatting should be good from my guide, but sometimes spacing can get off a bit.
Now press CTRL + X to exit the nano text editor.
Finally, we'll bring up our Trilium Notes syncing server with the command:
docker-compose up -d && docker-compose logs -f
This is really two commands concatenated together with the ‘&&’ signs. The first part docker-compose up -d
starts our image pulling down, and starts our container as a daemon in the background so it continues to run even if we close the terminal window. The second part docker-compose logs -f
tails the logs for us after the container is started. This just allows us to watch for any errors when we first start a new container.
Once, the image has downloaded, and the container is started, you'll see log output. When the output slows, or stops filling the xcreen with new information, you'll want to navigate in your favorite browser to the Web UI. You'll use the IP address of your host server (or localhost if you are running it on the same machine you are using), and the port you set on the left side of the por tmapping (I used port 8295).
I went to https://192.168.10.42:8295
in my browser.
Here' you'll be presented with the first run wizard for Tilium Notes. You'll need to choose whether you want to create a new notes document, or whether you have a server you want to sync, or a desktop client you want to sync. In our case, this is new, so we can choose the first option, then click the “Next” button.
Now you'll be prompted to create a password for your Trilium Notes system. Choose a long, strong pasword, and use something like Vaultwarden / Bitwarden to store the password so you don't have to remember it. Even better, use one of those apps to generate a strong password for you.
Click Finish and you'll be logged into your new Trilium Notes server. You'll see some preset (demo) notes that will help you see what all you can do with Trilium right out of the box. I have kept those demo notes so I can reference them as I continue to use the application and grow into it's capabilities.
The Trilium Desktop App
Next, you'll likely want a desktop app for keeping up with your notes as well. You may ask, “Why would I want a desktop app if I can just use the server for notes?” A valid question for certain.
The biggest reason, at least for me, is that the desktop app saves your notes locally on the desktop machine, but once you add the syncing server, the desktop app will also sync those notes to the server, and if you add notes or edit them directly on the server through a web browser, when you open the desktop app and it connects, it will sync those changes over.
- This is a great duplication strategy for not losing notes.
- Offline functionality on the desktop in case you don't have a network connection, or are outside the network where you have syncing setup.
There are builds for your various Desktop Operating Systems (OSes). For Windows there are .exe options in a zipped file, and for MacOS there are packages, also in a ziipped file. For LInux, you can get a .deb, or a zipped file with a binary in it, but I highly recommend getting it from Flathub as a Flatpak for Linux.
No matter which way you decide to install, get the desktop installed, then run it. You'll be presented again with the first run wizard. In order to start the app syncing with the server, you'll want to select option 3, then click next. Here, you'll be prompted to enter your server address, port, and Trilium Notes password. The proxy server address, is generally not something you'll need, but if you use a proxy server in order to reach the internet (and are serving your syncing server to the internet), or you need a proxy server to get to the rest of your network, then 1. you should know that already. 2. You should enter that information in the blank provided.
Once you've entered all of the data needed, click “Finish Setup”, and you should get your new Desktop app interface in front of you. On the left icon panel, you should see an icon near the bottom that looks like a Wifi signal icon. This icon should show white, with no other indicators near it when everything is synced. It will show slightly differently when you need to sync a change, or if it's not connected to your server. If you see it's not connected, just open the desktop app settings by clicking the Trilium logo in the upper left corner.
Trilium Icon >> Options >> Sync
This path will get you to the Syncing form. Double check your entries, then use the test button to make sure the sync is working.
Conclusion
You are set. You can now start taking notes like crazy, and you'll have some amazing syncing going on. If you are interested in syncing over the internet, then definitely check out my tutorials on setting up NGinX Proxy Manager, and using ti to expose your services to the internet, as well as getting valid SSL certificates through LetsEncrypt. It's a whole other guide, but well worth your time as you become a self hoster.
No Comments