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

0.96.0-rpi image - data persistence issue #1233

Closed
NlVlN opened this issue Dec 6, 2020 · 7 comments
Closed

0.96.0-rpi image - data persistence issue #1233

NlVlN opened this issue Dec 6, 2020 · 7 comments

Comments

@NlVlN
Copy link

NlVlN commented Dec 6, 2020

Describe the bug
n8n data is not persistent when using official docker image for Raspberry Pi and official instruction from docker hub's "Persist data" section (https://hub.docker.com/r/n8nio/n8n#persist-data).

To Reproduce
Steps to reproduce the behavior:

  1. Run the n8n from 0.96.0-rpi docker image with "-v ~/.n8n:/root/.n8n" option.
  2. Create and save a new workflow.
  3. No data exists in host's ~/.n8n directory.

Expected behavior
Data should be saved in the mounted directory / volume.

Environment:

  • OS: Raspbian 10
  • n8n Version: official n8nio/n8n:0.96.0-rpi docker image (also in previous versions)

Additional context
Probably the issue exists because n8n is executed as "node" user inside container because of line:

USER node

in Dockerfile and therefore, it is not able to save data to /root/.n8n directory.

@janober
Copy link
Member

janober commented Dec 6, 2020

Ah yes, thanks a lot. You are right. We will update the documentation it should be -v ~/.n8n:/home/node/.n8n

janober added a commit that referenced this issue Dec 6, 2020
@janober
Copy link
Member

janober commented Dec 6, 2020

Ok did update it on the website: https://n8n.io
and Dockerhub: https://hub.docker.com/repository/docker/n8nio/n8n

Also committed the fix the n8n-docs repository. So it should tomorrow also appear in the docs with the next docs-update.

@janober janober closed this as completed Dec 6, 2020
@NlVlN
Copy link
Author

NlVlN commented Dec 6, 2020

Hi @janober, thanks for your quick response but changing mount point did not resolve the issue.

I've tried running container with command:

# docker run -it --rm \      
     --name n8n_test \       
     -p 5678:5678 \    
     -v ~/.n8n:/home/node/.n8n \
     n8nio/n8n:0.96.0-rpi

and following error appeared:

UserSettings got generated and saved to: /home/node/.n8n/config
(node:7) UnhandledPromiseRejectionWarning: Error: There was an error: EACCES: permission denied, open '/home/node/.n8n/config'
    at Object.error (/usr/local/lib/node_modules/n8n/node_modules/@oclif/errors/lib/index.js:26:15)
    at Start.error (/usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js:60:23)
    at /usr/local/lib/node_modules/n8n/dist/commands/start.js:134:22
(node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:7) UnhandledPromiseRejectionWarning: Error: SQLITE_CANTOPEN: unable to open database file
(node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Could you reopen this issue?

@janober janober reopened this Dec 6, 2020
@janober
Copy link
Member

janober commented Dec 6, 2020

Sure can reopen it but if it does not work I guess the error message describes what the problem is. That it can not write to the file. So would try to delete the folder (~/.n8n) and see if it works then if you restart n8n. If you already have data saved you want to keep, you can also just rename it to test. If it is then working, check which access-rights and user the newly created folder and files have and then set the same for the previous one. It should then work fine.

@NlVlN
Copy link
Author

NlVlN commented Dec 8, 2020

Yeah, the problem is that by default n8n runs with "node" user privileges because of line in Dockerfile which I mentioned earlier. So if you just run command:

docker run -d \
    -p 5678:5678 \
    -v ~/.n8n:/root/.n8n # <- old method from documentation \
    n8nio/n8n:0.96.0-rpi

as root (which I think is the default method for most users) the whole n8n configuration won't be saved because user "node" inside container does not have privileges to write to root's ~/.n8n on host machine. And when you recreate n8n container (which in my case I did after a few days of happy using) you'll find out, that all config files were never saved and are gone now.

After changing container's bind mount from /root/.n8n to /home/node/.n8n, the error mentioned before appears.

So, quick workarounds that can be made are:

  1. Changing ownership of directory on host machine to UID and GID of node user from container:
# chown 1000:1000 /root/.n8n
  1. Building image locally without "USER node" line.
  2. Building image locally with:
RUN mkdir -p /home/node/.n8n && chown -R node:node /home/node/.n8n
VOLUME ["/home/node/.n8n"]

extra lines before:

USER node

line. This will work only if used with docker volume which does NOT exist yet. To run n8n this way use:

docker run -d \
    -p 5678:5678 \
    -v [VOLUME_NAME]:/home/node/.n8n \
    n8nio/n8n:0.96.0-rpi

My whole point is that everything should work from the beginning without a need to do some extra configuration. So I think Raspberry's version of the image should run n8n with root privileges like other versions does. If someone is willing to run it with less privileged user then custom image can be made locally.

@krynble
Copy link
Contributor

krynble commented Feb 10, 2021

Hey @NlVlN we released an update on version 0.99.0 that might have fixed this. You can find all the discussion in the link above.

Let me know if this solved the issue for you!

@janober
Copy link
Member

janober commented Jul 11, 2021

As we did not hear back for multiple months do I close this issue now. If the issue still persists for you please report back. Thanks!

@janober janober closed this as completed Jul 11, 2021
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

3 participants