Ask Your Question
4

Why are the variables in the .env file not accessible in the Nest.js app when using Docker?

asked 2023-07-17 15:01:44 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-17 15:10:02 +0000

lalupa gravatar image

When using Docker, the variables in the .env file may not be accessible in the Nest.js app due to the way Docker handles environment variables. Docker copies the environment variables when building the container and these variables are then set in the container's environment at runtime.

However, the .env file is not available inside the container unless it is explicitly copied during the build process. This means that the variables in the .env file are not available to the Nest.js app running inside the container.

To resolve this issue, you can either manually copy the .env file to the container or use a tool like docker-compose to manage environment variables. Another option is to use a package like dotenv to load environment variables from a file at runtime.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-17 15:01:44 +0000

Seen: 8 times

Last updated: Jul 17 '23