Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose ignores `configs:` section

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.

like image 268
sas Avatar asked Sep 13 '17 08:09

sas


1 Answers

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.

like image 106
BMitch Avatar answered Sep 21 '22 05:09

BMitch