How to correctly customize the n8n Dockerfile on Railway (without breaking login or DB migrations)?

I’m running n8n on Railway (Primary + Worker + Postgres + Redis, using queue mode) and wanted to customize the Dockerfile to add tools like curl and ffmpeg.

After switching from the default n8nio/n8n image to a custom Dockerfile (as suggested in the docs), I ran into problems:

  • Login fails with column User.apiKey does not exist
  • Looks like migrations aren’t running
  • Redis sometimes fails to connect in Worker mode

When I don’t use a Dockerfile (Railway default), everything works fine.


My Questions:

  1. Do both Primary and Worker need the Dockerfile separately?
  2. Can I use one Dockerfile for both and control behavior via N8N_ROLE?
  3. How do I make sure n8n migrate:up runs in Primary?
  4. Why does login break after switching to Docker?

Would love a clear example or best practice for custom Docker on Railway. Thanks!

Hey @AI_Blueprint,

Railway isn’t a platform we officially support but assuming you are using the same postgres and redis database it shouldn’t break unless the database is already in a bad state. Just changing a docker image unless you have done something really odd shouldn’t cause a problem.

How were you making the Dockerfile and was Railway previously using a Dockerfile or something else?

Please can you share your custom Dockerfile in a code block. Redact any sensitive values.