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?
Use -e or --env value to set environment variables (default []). If you want to use multiple environments from the command line then before every environment variable use the -e flag. Note: Make sure put the container name after the environment variable, not before that.
Also, supervisor is used when we need to run multiple process within the container. I have seen several examples where a container is started from base image and several service are installed and the container is committed to form a new image, all without supervisor.
Passing Environment Variables Into a DockerfileDockerfile provides a dedicated variable type ENV to create an environment variable. We can access ENV values during the build, as well as once the container runs.
A supervisor is a tool that allows us to manage a number of different processes simultaneously in Linux like operating system. The supervisor tool requires a . conf file where we specify the processes and different options related to that process like the output log location, auto start, auto restart, etc.
Try %(ENV_STAGE)s
.
The docs seem to suggest that's the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With