Reputation: 11
node.js application, built and deployed using docker-compose
, doesn't see any custom set variables. console.log(process.env.VAR)
logs undefined to console for any of those.
Variables are set using env_file property in yaml file. Only env_file property is used. There is an ENV value set in Dockerfile and it's accessible by the application.
docker exec -it <container-id> env
does return all custom values. docker exec -it <container-id> sh
returns only those set in base image - node-alpine (wiped out by exec?).
What can be wrong with the setup?
Upvotes: 0
Views: 469
Reputation: 11
I've found that the issue is not with the compose file or wrong usage of env_file field.
The issue was with the env file itself. It used spaces when setting values. Like this: VAR = VAL
instead of VAR=VAL
.
While dotenv npm package allows this (I've used a sample that comes with a project as a base for deployment), docker and environment don't.
Upvotes: 1