I'm trying to run a multi-process app in Docker with runit serving as init process but runit does not pass environment variables to the app:
In Dockerfile:
CMD ["runit"]
The service file /etc/service/app/run looks like this:
#!/bin/sh
exec 2>&1
echo "ENV_VAR=$ENV_VAR"
exec app
When I run the docker container with ENV_VAR set, the variable doesn't get passed to the app by runit. Output:
# docker run --name container -e ENV_VAR=loremipsum -d IMAGE_NAME
# docker logs container
- runit: $Id: 25da3b86f7bed4038b8a039d2f8e8c9bbcf0822b $: booting.
- runit: warning: unable to open /dev/console: file does not exist
- runit: enter stage: /etc/runit/1
/etc/runit/1: 6: /etc/runit/1: /etc/init.d/rcS: not found
/etc/runit/1: 7: /etc/runit/1: /etc/init.d/rmnologin: not found
/etc/runit/1: 12: /etc/runit/1: /etc/init.d/rc: not found
- runit: warning: child failed: /etc/runit/1
- runit: leave stage: /etc/runit/1
- runit: enter stage: /etc/runit/2
ENV_VAR=
...
* app failed because ENV_VAR was not set correctly *
How can I make runit pass the environment variable to the service/app?
you can try this way
or
example here
and