I’m having trouble with an n8n container in our GitHub Actions workflow. It works fine on our local machines but fails on the GitHub runner with a permission error:
Error: EACCES: permission denied, open '/home/node/.n8n/config'
Our docker-compose setup includes an n8n service that should expose an HTTP API. Here’s a snippet of our configuration:
n8n_service:
image: custom/n8n-image
ports:
- "5000:5000"
environment:
- N8N_HOST=n8n_service:5000
- N8N_PORT=5000
- N8N_PROTOCOL=http
- NODE_ENV=production
- DB_TYPE=postgres
- DB_PREFIX=n8n_
- DB_NAME=n8n_db
volumes:
- ./n8n_data:/home/n8n_user/.n8n
- ./n8n_files:/files
In our GitHub Actions workflow, we’ve tried:
- Creating a new user
- Setting up directories
- Changing permissions to 777
- Adjusting ownership
None of these steps have resolved the issue. The container won’t start and doesn’t log any errors. Any ideas on how to fix this or what might be causing the problem?
I encountered a similar issue with n8n in GitHub Actions. The problem might be related to the container user permissions. Try modifying your Dockerfile to explicitly set the user and group:
USER node
RUN mkdir -p /home/node/.n8n && chown -R node:node /home/node/.n8n
Also, ensure your workflow sets the correct permissions before running the container:
- name: Set permissions
run: |
sudo chown -R 1000:1000 ./n8n_data
sudo chmod -R 755 ./n8n_data
These steps should align the permissions between the host and container. If the issue persists, consider using the official n8n GitHub Actions instead of a custom container setup.
I’ve dealt with similar permission issues when running n8n in containers. One thing that often gets overlooked is the user ID mismatch between the host and container.
Try adding this to your docker-compose file:
n8n_service:
user: "${UID}:${GID}"
This will run the container with the same user/group IDs as your host system. You’ll need to export UID and GID in your GitHub Actions workflow before running docker-compose:
- name: Set UID and GID
run: |
echo "UID=$(id -u)" >> $GITHUB_ENV
echo "GID=$(id -g)" >> $GITHUB_ENV
Also, double-check that your n8n_data directory on the host has the correct permissions. You might need to create it beforehand in your workflow and set the right ownership.
If all else fails, you could try running the container as root (not ideal, but sometimes necessary for troubleshooting):
n8n_service:
user: "0:0"
Hope this helps you get to the bottom of the issue!
hey there! have u tried using a bind mount instead of a volume for the config directory? something like this:
volumes:
- ./n8n_data:/home/node/.n8n:Z
the :Z at the end might help with selinux permissions. also double-check ur user/group IDs match between host and container. good luck!