Reputation: 3373
Consider I have docker-compose.yaml
:
my-service:
build:
context: my-service/.
args:
- http_proxy
- https_proxy
command: -my-some-argument 100 %CONSUMER_ARGS%
networks:
- custom-network
docker-compose.yaml
is called via shell:
> docker-compose up
Argument my-some-argument
is passed to container properly. But somehow, environment variable %CONSUMER_ARGS%
is not replaced with proper value (literal string %CONSUMER_ARGS%
is passed to container). So is there other way to pass arguments to my container while calling docker-compose up
? Dokcer is running windows, containers under linux images.
Upvotes: 1
Views: 100
Reputation: 131
Your templating syntax for env variable replacement is not correct. Use
${ENV_PASSED_VALUE:-DEFAULT_VALUE}
Upvotes: 0
Reputation: 850
You can use environmental variables in compose like this:
my-service:
build:
context: my-service/.
args:
- http_proxy
- https_proxy
command: -my-some-argument 100 ${CONSUMER_ARGS}
networks:
- custom-network
Note the ${}
instead of %%
More info here: https://docs.docker.com/compose/environment-variables/
Upvotes: 2