I've got a docker-compose service definition with a configs section as follows:
# api.yml file
version: '3.3'
services:
api:
...
configs:
- source: api_config
target: /env.cfg
configs:
api_config:
file: ./config/my.cfg
When I use this file to drive a swarm, i.e. I deploy it with docker stack deploy ...
the config file is properly provided into the running containers.
However, when I try to run a local version of the api via docker-compose -f api.yml up
I get a startup failure complaining of my api service that it can't find its config. (NB: docker-compose itself doesn't report any errors.)
Are configs
sections not supported with plain docker-compose
usage?
The docs don't explicitly say so although some wording seems to indicate this is for stacks only:
Note: The config must already exist or be defined in the top-level configs configuration of this stack file, or stack deployment will fail.
Configs and secrets are implemented using the embedded raft key value store provided by swarm mode. Those features aren't available to containers not running as part of swarm mode yet, so they will be ignored by docker-compose.
https://docs.docker.com/engine/swarm/configs/#about-configs
Note: Docker configs are only available to swarm services, not to standalone containers. To use this feature, consider adapting your container to run as a service with a scale of 1.
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