# Start from the official n8n image FROM n8nio/n8n:latest # Switch to the root user temporarily to gain permissions USER root # Create the data directory (if it doesn't exist) and # change its owner to the 'node' user, which is what n8n runs as. # The -R flag means "recursively", applying to all sub-folders. RUN mkdir -p /data/n8n_data && chown -R node:node /data # Switch back to the non-root 'node' user for security before running the app USER node