Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(docker): mount the data directory relative to the compose file
Elian Doran0a2b7d7064a3
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.htmlindex a67fc288a6..bc48466c16 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.html@@ -17,8 +17,11 @@<h3>Grab the latest docker-compose.yml:</h3><pre><code class="language-text-x-trilium-auto">wget https://raw.githubusercontent.com/TriliumNext/Trilium/master/docker-compose.yml</code></pre><p>Optionally, edit the <code>docker-compose.yml</code> file to configure thecontainer settings prior to starting it. Unless configured otherwise, the- data directory will be <code>~/trilium-data</code> and the container will- be accessible at port 8080.</p>+ data directory will be <code>trilium-data</code> next to <code>docker-compose.yml</code> and+ the container will be accessible at port 8080.</p>+<p>To keep the data somewhere else, edit the <code>volumes</code> entry in <code>docker-compose.yml</code> and+ change the host path before the colon (for example <code>- /srv/trilium-data:/home/node/trilium-data</code>).+ Leave the path after the colon unchanged.</p><h3>Start the container:</h3><p>Run the following command to start the container in the background:</p><pre><code class="language-text-x-trilium-auto">docker compose up -d</code></pre><h2>Running without Docker Compose / Further Configuration</h2>@@ -111,9 +114,6 @@ docker-compose -f docker-compose.rootless.yml up -d# Run with custom UID/GID (e.g., match your host user)TRILIUM_UID=$(id -u) TRILIUM_GID=$(id -g) docker-compose -f docker-compose.rootless.yml up -d--# Specify a custom data directory-TRILIUM_DATA_DIR=/path/to/your/data TRILIUM_UID=$(id -u) TRILIUM_GID=$(id -g) docker-compose -f docker-compose.rootless.yml up -d</code></pre><h4><strong>Using Docker CLI</strong></h4><pre><code class="language-text-x-trilium-auto"># Build the imagedocker build -t triliumnext/trilium:rootless -f apps/server/Dockerfile.rootless .@@ -130,8 +130,6 @@ docker run -d --name trilium -p 8080:8080 --user $(id -u):$(id -g) -v ~/trilium-to Docker's <code>--user</code> flag)</li><li><code>TRILIUM_GID</code>: GID to use for the container process (passedto Docker's <code>--user</code> flag)</li>- <li><code>TRILIUM_DATA_DIR</code>: Path to the data directory inside the container- (default: <code>/home/node/trilium-data</code>)</li></ul><p>For a complete list of configuration environment variables (network settings,authentication, sync, etc.), see <a class="reference-link" href="#root/_help_Gzjqa934BdH4">Configuration (config.ini or environment variables)</a>.</p>diff --git a/docker-compose.rootless.yml b/docker-compose.rootless.ymlindex 7d4afd5452..396e415d36 100644--- a/docker-compose.rootless.yml+++ b/docker-compose.rootless.yml@@ -1,17 +1,13 @@-version: '3.8'--# Running `docker-compose -f docker-compose.rootless.yml up` will create/use the "trilium-data" directory in the user home-# Run `TRILIUM_DATA_DIR=/path/of/your/choice docker-compose -f docker-compose.rootless.yml up` to set a different directory+# Running `docker-compose -f docker-compose.rootless.yml up` will create/use the "trilium-data" directory next to this file# To run in the background, use `docker-compose -f docker-compose.rootless.yml up -d`-# To use the Alpine-based image, run with `TRILIUM_VARIANT=alpine docker-compose -f docker-compose.rootless.yml up`+# To use the Alpine-based image, change the image tag below to `rootless-alpine`services:trilium:# Optionally, replace `latest` with a version tag like `v0.90.3`# Using `latest` may cause unintended updates to the container- image: triliumnext/notes:rootless+ image: triliumnext/trilium:rootlessrestart: unless-stoppedenvironment:- - TRILIUM_DATA_DIR=/home/trilium/trilium-data# Set the desired UID/GID for the Trilium process. Will be used during docker run# These should match the owner of your data directory on the host- TRILIUM_UID=${TRILIUM_UID:-1001}@@ -24,8 +20,8 @@ services:# You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules- '8080:8080'volumes:- # Unless TRILIUM_DATA_DIR is set, the data will be stored in the "trilium-data" directory in the home directory.- # This can also be changed by replacing the line below with `- /path/of/your/choice:/home/trilium/trilium-data- - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/trilium/trilium-data+ # Trilium stores its data in `trilium-data` next to this file. To use another directory+ # on the host, change the part before the colon only.+ - ./trilium-data:/home/trilium/trilium-data- /etc/timezone:/etc/timezone:ro- /etc/localtime:/etc/localtime:rodiff --git a/docker-compose.yml b/docker-compose.ymlindex ba9824c7c4..e7a23457a7 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -1,5 +1,4 @@-# Running `docker-compose up` will create/use the "trilium-data" directory in the user home-# Run `TRILIUM_DATA_DIR=/path/of/your/choice docker-compose up` to set a different directory+# Running `docker-compose up` will create/use the "trilium-data" directory next to this file# To run in the background, use `docker-compose up -d`services:trilium:@@ -8,8 +7,6 @@ services:image: triliumnext/trilium:latest# Restart the container unless it was stopped by the userrestart: unless-stopped- environment:- - TRILIUM_DATA_DIR=/home/node/trilium-dataports:# By default, Trilium will be available at http://localhost:8080# It will also be accessible at http://<host-ip>:8080@@ -18,8 +15,8 @@ services:# https://docs.docker.com/engine/network/packet-filtering-firewalls/#docker-and-ufw- '8080:8080'volumes:- # Unless TRILIUM_DATA_DIR is set, the data will be stored in the "trilium-data" directory in the home directory.- # This can also be changed with by replacing the line below with `- /path/of/your/choice:/home/node/trilium-data- - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/node/trilium-data+ # Trilium stores its data in `trilium-data` next to this file. To use another directory+ # on the host, change the part before the colon only.+ - ./trilium-data:/home/node/trilium-data- /etc/timezone:/etc/timezone:ro- /etc/localtime:/etc/localtime:rodiff --git a/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.md b/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.mdindex f059d9a9ab..de1eaf66b6 100644--- a/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.md+++ b/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Using Docker.md@@ -20,7 +20,9 @@ If you need help installing Docker, reference the [Docker Installation Docs](httwget https://raw.githubusercontent.com/TriliumNext/Trilium/master/docker-compose.yml```-Optionally, edit the `docker-compose.yml` file to configure the container settings prior to starting it. Unless configured otherwise, the data directory will be `~/trilium-data` and the container will be accessible at port 8080.+Optionally, edit the `docker-compose.yml` file to configure the container settings prior to starting it. Unless configured otherwise, the data directory will be `trilium-data` next to `docker-compose.yml` and the container will be accessible at port 8080.++To keep the data somewhere else, edit the `volumes` entry in `docker-compose.yml` and change the host path before the colon (for example `- /srv/trilium-data:/home/node/trilium-data`). Leave the path after the colon unchanged.### Start the container:@@ -162,9 +164,6 @@ docker-compose -f docker-compose.rootless.yml up -d# Run with custom UID/GID (e.g., match your host user)TRILIUM_UID=$(id -u) TRILIUM_GID=$(id -g) docker-compose -f docker-compose.rootless.yml up -d-# Specify a custom data directory-TRILIUM_DATA_DIR=/path/to/your/data TRILIUM_UID=$(id -u) TRILIUM_GID=$(id -g) docker-compose -f docker-compose.rootless.yml up -d-```#### **Using Docker CLI**@@ -185,7 +184,6 @@ docker run -d --name trilium -p 8080:8080 --user $(id -u):$(id -g) -v ~/trilium-* `TRILIUM_UID`: UID to use for the container process (passed to Docker's `--user` flag)* `TRILIUM_GID`: GID to use for the container process (passed to Docker's `--user` flag)-* `TRILIUM_DATA_DIR`: Path to the data directory inside the container (default: `/home/node/trilium-data`)For a complete list of configuration environment variables (network settings, authentication, sync, etc.), see <a class="reference-link" href="../../../Advanced%20Usage/Configuration%20(config.ini%20or%20environment%20variables).md">Configuration (config.ini or environment variables)</a>.