Hi all,
I'm migrating my Node-RED deployment from systemd
to Docker Compose, and I'm running into an issue with environment variables.
Previously, when using systemctl
, I used an EnvironmentFile=/etc/nodered/.env
in my service unit. This allowed me to access environment variables directly in Node-RED via env.get("MY_VAR")
inside function nodes.
Now, in my Docker Compose setup, I have:
services:
app:
image: ${IMAGE}
env_file:
- ../../.env
environment:
- NODE_RED_CREDENTIAL_SECRET=${NODE_RED_CREDENTIAL_SECRET}
I verified with docker compose config
that the variables are injected correctly into the container. But when I use env.get("MY_VAR")
, it returns ""
.
Is there a way to make env.get()
work with environment variables passed via Docker (like it did with systemd)? I have over 20 environment variables, so manually declaring each one in settings.js
feels quite unmaintainable. The simplest and most scalable solution for me is to use a .env
file and access variables using env.get()
as before.
Is there any recommended way to make env.get()
work with variables from Docker’s env_file
, similar to how it worked with systemd's EnvironmentFile
?
Thank you!