Search code examples
dockersupervisord

Pass environment variable from docker to supervisord


I pass two env variables with docker run:

docker run -d --name foobar -e STAGE=testing -e STAGE_URL=http://...

and the dockerfile kicks of supervisor which launches a couple of processes:

CMD ["/usr/bin/supervisord", "--configuration", "/etc/supervisor/conf.d/supervisord.conf"]

In the supervisord.conf I try to read the variables:

[program:build]
priority=1
autorestart=false
directory=/app/foobar
command=grunt build --force --stage ${STAGE} --stage-url ${STAGE_URL}

I tried also with

$STAGE

and

%(STAGE)s

But STAGE is never treated as a variable. It is never replaced with the actual content. Instead it is treated as a simple string. This results in:

--stage STAGE --stage-url STAGE_URL

instead of

--stage testing --stage-url http://...

Is this even possible what I am doing? Supervisor docs are not clear about this topic. Any ideas?


Solution

  • Try %(ENV_STAGE)s.

    The docs seem to suggest that's the way to go.