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

docker install error: EACCES: permission denied, open '/home/node/.n8n/config' still happens #11102

Closed
UlyssesWu opened this issue Oct 4, 2024 · 6 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@UlyssesWu
Copy link

Bug Description

#1240

Same problem still happens on the latest version. I could not find the fix line in latest docker/images/n8n/docker-entrypoint.sh

4a98fe4

To Reproduce

see #1240

Expected behavior

see #1240

Operating System

Linux (unknown version) with docker

n8n Version

1.61.0

Node.js Version

20.17.0

Database

SQLite (default)

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Oct 4, 2024

Hey @UlyssesWu,

We have created an internal ticket to look into this which we will be tracking as "GHC-283"

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Oct 4, 2024
@Joffcom
Copy link
Member

Joffcom commented Oct 4, 2024

Hey @UlyssesWu

This is not an issue we have seen for a long time, assuming the node user in the container owns the folder everything should be working.

Can you share how you have n8n deployed?

If you have upgraded from an older version (before 1.0) check out the information here: https://docs.n8n.io/1-0-migration-checklist/#docker

@netroy
Copy link
Member

netroy commented Oct 4, 2024

The chown was moved from the entrpoint into the Dockerfile here.

The assumption we make here is that when a user is mounting a directory into n8n container or using a volume, they are the ones responsible for making sure that n8n container has write permissions.
We don't want to do a chown in the entrypoint because

  1. We now do not have the permission to do so, since we don't run n8n as the root user anymore
  2. it's not n8n's responsibility to fix permissions on a filesystem that it does not own.

@UlyssesWu
Copy link
Author

Thanks for the explaination, that was quick.
I was trying to deploy n8n on my NAS. It's using its custom GUI for docker.
It did has the feature to mount directory with write permission. And it did work for many other docker images I have tried so far.
However it throws errors for the n8n image if I mount the /home/node/.n8n directory. If I don't mount, it works fine.

Here is the screenshot for it's log:
7f91813da9b23681914154c9628abed9

(If I mount the directory with readonly permission, the error will be message: EROFS: read-only file system, open '/home/node/.n8n/config')

I also noticed someone else was saying this issue still happens: saltyorg/Sandbox#301 (comment)

Now I consider it might be a fault on the NAS OS side. Thanks again.

@UlyssesWu
Copy link
Author

UlyssesWu commented Oct 4, 2024

To everyone who is using docker in NAS and facing the same problem, the workaround could be:

  1. mount /home/node/n8n (not .n8n)
  2. Start the container
  3. SSH command cp -r /home/node/.n8n/* /home/node/n8n/
  4. SSH command chown -R node /home/node/n8n
  5. In your NAS's docker setting panel, change mount /home/node/n8n to /home/node/.n8n

The problem is, if you mount /home/node/.n8n at the beginning, the container will soon restart because of error and you won't have chance to execute commands like chown.

@remkolems
Copy link

remkolems commented Oct 6, 2024

Unfortunately, I encountered the same error on my Ubuntu host. See the docker-compose.yml file for more configuration details: applicable to

Update

Error

When docker compose up -d is successfully executed, I do get the following error message for n8n container:

(node:7) [EACCES] Warning: Error
module: @oclif/core@4.0.7
task: findCommand (license:clear)
plugin: n8n
root: /usr/local/lib/node_modules/n8n
code: EACCES
message: EACCES: permission denied, open '/home/node/.n8n/config'
See more details with DEBUG=*

Details

> docker compose up -d
[+] Running 4/4
 ✔ Network n8n_n8n         Created                                                                                                                                                                                                                                                                                               0.1s 
 ✔ Container redis-n8n     Healthy                                                                                                                                                                                                                                                                                               6.1s 
 ✔ Container postgres-n8n  Healthy                                                                                                                                                                                                                                                                                               6.1s 
 ✔ Container n8n           Started
# This is with docker compose up -d
# /home/docker/n8n/n8n remains empty
> ls -ld /home/docker/n8n/{n8n,postgres_data,redis_data} /home/docker/n8n/

drwxr-xr-x  5 root root 4096 Oct  6 19:57 /home/docker/n8n/
drwxr-xr-x  2 root root 4096 Oct  6 19:57 /home/docker/n8n/n8n
drwx------ 19   70 root 4096 Oct  6 19:57 /home/docker/n8n/postgres_data
drwxr-xr-x  2 lxd  root 4096 Oct  6 19:57 /home/docker/n8n/redis_data

image

# Tested and set `init-data.sh` with/without `chmod +x init-data.sh`
> ls -lah
total 24K
drwxrwxr-x  2 admin admin 4.0K Oct  6 20:26 .
drwxrwxr-x 42 admin admin 4.0K Oct  6 12:43 ..
-rw-rw-r--  1 admin admin 3.1K Oct  6 20:20 docker-compose.yml
-rw-rw-r--  1 admin admin  307 Oct  6 20:27 .env
-rwxrwxr-x  1 admin admin  500 Oct  6 14:46 init-data.sh
-rw-rw-r--  1 admin admin  572 Oct  6 14:40 README.md

Do note: ${N8N_HOME} == /home/docker/n8n

# docker-compose.yml
#
# https://github.com/n8n-io/n8n-hosting
## https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgresAndWorker
#
# Queue mode disabled for now. MVP and as simple as possible.
#
x-shared: &shared
  # https://github.com/n8n-io/n8n/pkgs/container/n8n
  # image: reg.<harbor>.com/ghcr.io/n8n-io/n8n:1.62.1
  image: reg.<harbor>.com/ghcr.io/n8n-io/n8n:1.61.0
  restart: unless-stopped
  env_file:
    - .env
  environment:
    # https://docs.n8n.io/hosting/configuration/environment-variables/#environment-variables-overview
    - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
    - N8N_PORT=${N8N_PORT}
    - N8N_PROTOCOL=http # HAProxy SSL offload
    - NODE_ENV=production
    - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
    - GENERIC_TIMEZONE=${TZ}
    # - EXECUTIONS_MODE=queue # see https://docs.n8n.io/hosting/scaling/queue-mode/#queue-mode
    - DB_TYPE=postgresdb
    - DB_POSTGRESDB_HOST=postgres
    - DB_POSTGRESDB_PORT=${POSTGRES_PORT}
    - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
    - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
    - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
    - QUEUE_BULL_REDIS_HOST=redis
    - QUEUE_BULL_REDIS_PORT=${REDIS_PORT}
    - QUEUE_HEALTH_CHECK_ACTIVE=true
  links:
    - postgres
    - redis
  volumes:
    - "${N8N_HOME}/n8n:/home/node/.n8n"
  depends_on:
    redis:
      condition: service_healthy
    postgres:
      condition: service_healthy
  networks:
    - n8n

services:
  postgres:
    # https://hub.docker.com/_/postgres/tags?page=1&name=alpine3.
    image: reg.<harbor>.com/hub.docker.com/library/postgres:17.0-alpine3.20
    container_name: postgres-n8n
    # hostname: postgres-n8n
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "${POSTGRES_PORT:-7432}:5432"
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB
      - POSTGRES_NON_ROOT_USER
      - POSTGRES_NON_ROOT_PASSWORD
    volumes:
      - "${N8N_HOME}/postgres_data:/var/lib/postgresql/data"
      - ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}",
        ]
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - n8n

  # https://docs.n8n.io/hosting/scaling/queue-mode/#start-redis
  redis:
    # https://hub.docker.com/_/redis/tags?name=alpine3.
    image: reg.<harbor>.com/hub.docker.com/library/redis:7.4.0-alpine3.20
    container_name: redis-n8n
    # hostname: redis-n8n
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - ${REDIS_PORT}:6379
    volumes:
      - "${N8N_HOME}/redis_data:/data"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - n8n

  n8n:
    <<: *shared
    container_name: n8n
    ports:
      - 5678:5678

  # # Worker and queue mode: https://docs.n8n.io/hosting/scaling/queue-mode/#queue-mode
  # n8n-worker:
  #   <<: *shared
  #   command: worker
  #   depends_on:
  #     - n8n

networks:
  n8n:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

4 participants