I’m having trouble with our docker compose setup in GitHub Actions. It works fine on our local machines (macOS), but fails on the GitHub runner with a permission error:
Error: EACCES: permission denied, open '/home/node/.n8n/config'
This happens with our n8n container, which should start an HTTP API. Here’s a snippet from our docker-compose file:
have u tried runnin the container as root? add user: root to ur compose file for the n8n service. also check if the volume paths exist on the runner. sometimes these issues happen cuz of missin directories. lemme kno if that helps!
The permission issue you’re encountering is likely due to the mismatch between the container’s user and the host system’s file ownership. Instead of modifying the container to run as root, which can pose security risks, consider adjusting your approach:
Update your docker-compose file to use a named volume for n8n data:
volumes:
- n8n_data:/home/node/.n8n
Modify your GitHub Actions workflow to create and set permissions on this volume:
This method ensures proper permissions without compromising security. It also simplifies your setup by avoiding host-bound volumes, which can be tricky in CI environments.
I’ve dealt with similar permission issues when running containers in CI environments. One approach that’s worked well for me is using the --user flag in your docker-compose file to match the UID and GID of the host system. You can do this dynamically in your GitHub Actions workflow:
This ensures the container processes run with the same permissions as the GitHub Actions runner, which should resolve the EACCES error. Also, double-check that your volume paths are correct and accessible on the runner. If issues persist, you might need to initialize the volume directories with the correct permissions before starting the containers.