Next.js Discord

Discord Forum

How to give environment variables at run time while running a docker image?

Unanswered
devv posted this in #help-forum
Open in Discord
I have an app which would have a different environment for each deployment.

So it makes sense to build its docker images such that I only build a version of this app and pass environment variables while running the container instead of building the image with the environment.

But in the documentation it says that environment variables are replaced at build time. Is there any way I can do this?

(I am using nextjs app router)

2 Replies