self hosting
N8N Docker Compose .env File
A Docker Compose env file keeps n8n deployment settings separate from the Compose service definition and makes it easier to avoid committing secrets.
Independent third-party notes. n8n is a trademark of its owner and is referenced only for compatibility and troubleshooting context.
Quick Answer
A Docker Compose env file keeps n8n deployment settings separate from the Compose service definition and makes it easier to avoid committing secrets.
Key Facts
- Best use
- Store deployment-specific environment variables outside the Compose service body.
- Typical values
- Database, Redis, endpoint, timezone, encryption, and node settings.
- Security reason
- Secrets should not be committed to public repositories.
- Operational reason
- The same Compose file can be reused across environments.
Recommended Steps
- Move environment-specific values into a local env file.
- Reference the env file from the Compose service.
- Keep secret values out of version control.
- Restart the Compose stack after editing variables.
- Check logs for malformed or missing variable values.
Verification
- Compose starts n8n with the expected variables.
- The env file is ignored by Git or otherwise protected.
- The same Compose file can run with a different env file in staging.
Warnings
- An env file is still sensitive if it contains secrets.
- Changing env values without restarting n8n may leave the old configuration active.