Docker container permission error in CI/CD environment but works fine on local machine

I have a docker compose setup that runs perfectly on my local machine but keeps failing when I try to run it in GitHub Actions. The error I get is:

Error: EACCES: permission denied, open '/home/node/.n8n/config'

Here’s my docker compose configuration:

  automation-service:
    image: docker.n8n.io/n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=automation-service:5678
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - DB_TYPE=postgresdb
      - DB_TABLE_PREFIX=workflow_
      - DB_POSTGRESDB_DATABASE=workflows
    volumes:
      - ./docker/automation/data:/home/node/.n8n
      - ./docker/automation/files:/files

In my GitHub workflow I’m doing:

sudo useradd -m node
mkdir -p docker/automation
sudo chmod -R 777 docker/automation
sudo chown -R node:node docker/automation
docker-compose up -d

I’ve tried different permission combinations including 777 and various user ownership changes but nothing works. The container starts locally without any issues. What could be causing this permission problem in the CI environment?

Sounds like SELinux or AppArmor is blocking something in CI. Try the --privileged flag with docker run, or set privileged: true in your compose file. GitHub Actions uses different Docker daemon settings than your local machine, so volume permissions get weird.

I encountered a similar issue with n8n containers in CI pipelines. GitHub Actions runners have different filesystem semantics compared to your local Docker daemon. Instead of altering host permissions, consider using a named volume for the n8n data directory instead of bind mounts.

Modify your volume configuration to:

volumes:
  - n8n_data:/home/node/.n8n
  - ./docker/automation/files:/files

Then, add this at the bottom of your compose file:

volumes:
  n8n_data:

This approach allows Docker to manage permission mapping autonomously, eliminating potential host filesystem complications. It functions effectively across diverse CI environments like GitHub Actions and GitLab CI, with the container creating and managing the volume with the correct permissions.

This happens because GitHub Actions handles Docker volume mounts and file permissions differently than your local machine. Docker runs with different user mappings in CI environments.

Try adding the user spec directly to your docker-compose file:

automation-service:
  image: docker.n8n.io/n8nio/n8n
  user: "1001:1001"
  ports:
    - "5678:5678"

Or create the directories and set ownership first:

mkdir -p docker/automation/data docker/automation/files
sudo chown -R 1001:1001 docker/automation
docker-compose up -d

Use the specific UID/GID that n8n expects (1001) instead of creating a new node user on the host. GitHub Actions runners have different user contexts - that’s why it works locally but breaks in CI.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.