Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Bug report) v0.90.4 docker does not read USER_UID and USER_GID from environment #331

Open
yu-jingrui opened this issue Aug 11, 2024 · 6 comments
Milestone

Comments

@yu-jingrui
Copy link

TriliumNext Version

0.90.4

What operating system are you using?

Windows

What is your setup?

Local + server sync

Operating System Version

windows 11

Description

Docker server is deployed on synology DS920+ with container manager. After updating to 0.90.4 from 0.94.3, the docker instance shuts down with error code -13. It keeps setting uid and gid to 1000 although they are specified in environment. Here is the compose file:

version: "3"
services:
  trilium:
    image: triliumnext/notes:v0.90.4
    container_name: triliumnext
    restart: unless-stopped
    hostname: triliumnext
    volumes:
      - ./trilium-data:/home/node/trilium-data
    environment:
      USER_UID: xxxx
      USER_GID: xxxxx
    ports:
      - xxxxx:8080

Error logs

2024/8/11 16:09 stderr Node.js v20.15.1
2024/8/11 16:09 stderr
2024/8/11 16:09 stderr }
2024/8/11 16:09 stderr path: '/home/node/trilium-data/log'
2024/8/11 16:09 stderr " syscall: 'mkdir',"
2024/8/11 16:09 stderr " code: 'EACCES',"
2024/8/11 16:09 stderr " errno: -13,"
2024/8/11 16:09 stderr at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5) {
2024/8/11 16:09 stderr at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
2024/8/11 16:09 stderr at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
2024/8/11 16:09 stderr at file:///usr/src/app/src/services/log.js:6:8
2024/8/11 16:09 stderr at Object.mkdirSync (node:fs:1372:26)
2024/8/11 16:09 stderr "Error: EACCES: permission denied, mkdir '/home/node/trilium-data/log'"
2024/8/11 16:09 stderr
2024/8/11 16:09 stderr ^
2024/8/11 16:09 stderr const result = binding.mkdir(
2024/8/11 16:09 stderr node:fs:1372
2024/8/11 16:09 stderr (Use node --trace-warnings ... to show where the warning was created)
2024/8/11 16:09 stderr (node:9) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
2024/8/11 16:09 stdout "No USER_GID specified, leaving 1000"
2024/8/11 16:09 stdout "No USER_UID specified, leaving 1000"
2024/8/11 16:09 stderr ./start-docker.sh: 4: [[: not found
2024/8/11 16:09 stderr ./start-docker.sh: 3: [[: not found
2024/8/11 16:09 stderr Node.js v20.15.1
2024/8/11 16:09 stderr
2024/8/11 16:09 stderr }
2024/8/11 16:09 stderr path: '/home/node/trilium-data/log'
2024/8/11 16:09 stderr " syscall: 'mkdir',"
2024/8/11 16:09 stderr " code: 'EACCES',"
2024/8/11 16:09 stderr " errno: -13,"
2024/8/11 16:09 stderr at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5) {
2024/8/11 16:09 stderr at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
2024/8/11 16:09 stderr at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
2024/8/11 16:09 stderr at file:///usr/src/app/src/services/log.js:6:8
2024/8/11 16:09 stderr at Object.mkdirSync (node:fs:1372:26)
2024/8/11 16:09 stderr "Error: EACCES: permission denied, mkdir '/home/node/trilium-data/log'"
2024/8/11 16:09 stderr
2024/8/11 16:09 stderr ^
2024/8/11 16:09 stderr const result = binding.mkdir(
2024/8/11 16:09 stderr node:fs:1372
2024/8/11 16:09 stderr (Use node --trace-warnings ... to show where the warning was created)
2024/8/11 16:09 stderr (node:9) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
2024/8/11 16:09 stdout "No USER_GID specified, leaving 1000"
2024/8/11 16:09 stdout "No USER_UID specified, leaving 1000"
2024/8/11 16:09 stderr ./start-docker.sh: 4: [[: not found
2024/8/11 16:09 stderr ./start-docker.sh: 3: [[: not found

@eliandoran
Copy link
Contributor

@yu-jingrui , thank you for the detailed report.

I believe this got broken when we switched from alpine to debian-slim due to issues with ARM builds.

I've pushed a fix to develop. If you have the time to check: https://hub.docker.com/layers/triliumnext/notes/develop/images/sha256-54b46770713f9bae776f2bf45d7bdcf524eeee94c5dd0421634b6d0b5133fd90?context=repo

If not, you could always fall back to an older version and move to the next stable release, which I think will only come in a few weeks (we'll release some betas for internationalization first).

@eliandoran eliandoran added this to the v0.90.5-beta milestone Aug 12, 2024
@yu-jingrui
Copy link
Author

@yu-jingrui , thank you for the detailed report.

I believe this got broken when we switched from alpine to debian-slim due to issues with ARM builds.

I've pushed a fix to develop. If you have the time to check: https://hub.docker.com/layers/triliumnext/notes/develop/images/sha256-54b46770713f9bae776f2bf45d7bdcf524eeee94c5dd0421634b6d0b5133fd90?context=repo

If not, you could always fall back to an older version and move to the next stable release, which I think will only come in a few weeks (we'll release some betas for internationalization first).

I tried develop and it seems to be working correctly. Thanks for the quick fix. I will wait for the next stable release and use 0.90.3 for the moment.

@l-33ter
Copy link

l-33ter commented Aug 22, 2024

TriliumNext Version
0.90.4

What operating system are you using?
Debian12

Yes, I encountered the same error as well. I haven't attempted your fix on the develop branch yet; I want to type out the error first.

# https://github.com/TriliumNext/Notes
# 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
# To run in the background, use `docker-compose up -d`
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:v0.90.4
    container_name: triliumnext-notes
    # Restart the container unless it was stopped by the user
    restart: unless-stopped
    environment:
      TRILIUM_DATA_DIR: ${TRILIUM_DATA_DIR}
      USER_UID: ${USER_UID}
      USER_GID: ${USER_GID}
    ports:
      # By default, Trilium will be available at http://localhost:8080
      # It will also be accessible at http://<host-ip>:8080
      # You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules, such as UFW
      - '9991:8080'
    networks:
      - proxy
    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

networks:
  proxy:
    external: true
No USER_UID specified, leaving 1000
No USER_GID specified, leaving 1000
./start-docker.sh: 3: [[: not found
./start-docker.sh: 4: [[: not found
(node:9) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:fs:1372
  const result = binding.mkdir(
                         ^

Error: ENOENT: no such file or directory, mkdir '/home/mrcl/Adocker/Project-TEST/August_2024/TriliumNext/my-data/'
    at Object.mkdirSync (node:fs:1372:26)
    at getTriliumDataDir (file:///usr/src/app/src/services/data_dir.js:33:16)
    at file:///usr/src/app/src/services/data_dir.js:47:26
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: '/home/mrcl/Adocker/Project-TEST/August_2024/TriliumNext/my-data/'
}

EDIT with develop-image

One thing I don't understand, if I set TRILIUM_DATA_DIR (and I checked it before running docker compose with docker compose config that everything will be on their right places) - the container FAILED with the above error

However if I comment-out the TRILIUM_DATA_DIR and set the volumes directly:

# https://github.com/TriliumNext/Notes
# 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
# To run in the background, use `docker-compose up -d`
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:develop
    container_name: triliumnext-notes
    # Restart the container unless it was stopped by the user
    restart: unless-stopped
    environment:
      # TRILIUM_DATA_DIR: ${TRILIUM_DATA_DIR} #COMMENT-THIS-OUT!!!
      USER_UID: ${USER_UID}
      USER_GID: ${USER_GID}
    ports:
      # By default, Trilium will be available at http://localhost:8080
      # It will also be accessible at http://<host-ip>:8080
      # You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules, such as UFW
      - '9991:8080'
    networks:
      - proxy
    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
      - ./mydata:/home/node/trilium-data

networks:
  proxy:
    external: true

Everything works perfectly clear!!

image

@PDiracDelta
Copy link

This bug still exists; I'm using triliumnext/notes:latest as of today (2024-12-30)
Please fix <3

@eliandoran
Copy link
Contributor

@PDiracDelta , could you please provide more info? Is it the same issue as the OP, or is it something slightly different?

@PDiracDelta
Copy link

PDiracDelta commented Dec 31, 2024

@PDiracDelta , could you please provide more info? Is it the same issue as the OP, or is it something slightly different?

Indeed it's a bit different. To clarify, I'm talking about the issue mentioned below, from OP's last reply. Should I make a different ticket?

... if I set TRILIUM_DATA_DIR (and I checked it before running docker compose with docker compose config that everything will be on their right places) - the container FAILED with the above error. However if I comment-out the TRILIUM_DATA_DIR and set the volumes directly ... Everything works perfectly clear!!

@eliandoran eliandoran reopened this Jan 2, 2025
@eliandoran eliandoran removed the bug label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants