Compose: Compose does not support 'configs' configuration with v3.3

Created on 16 Aug 2017  路  23Comments  路  Source: docker/compose

Docker version 17.07.0-ce-rc2, build 36ce605
docker-compose version 1.15.0, build e12f3b9

sample config

version: "3.3"
configs:
  config.yml:
    file: ../config/config.yml
services:
  php:
    image: php:7.1-fpm
    configs:
      - source: config.yml
        target: /configs/config.yml

returns
WARNING: Some services (php) use the 'configs' key, which will be ignored. Compose does not support 'configs' configuration - usedocker stack deployto deploy to a swarm.

areconfig formav3 kinquestion

Most helpful comment

Looks like documentation is written in a science-fiction manner.

All 23 comments

What is your question?

According to the documentation this should be supported: https://docs.docker.com/compose/compose-file/#short-syntax

So what is the correct solution to using configs in docker-compose v3.3? I am unable to deploy a stack (or is it a swarm) without completely redesigning compose files and this is a massive headache compared to the functionality of the previous minor release.

Configs are only used when you deploy on Swarm mode using docker stack deploy. Compose recognizes the option as valid, but does not use the section as it is a feature only available for Swarm mode services / stacks.

HTH

Does the same apply to secrets now?

We went with a compromise for the secrets implementation, see #4994 for details.

Looks like documentation is written in a science-fiction manner.

I wish a compromise would also be taken for extends (see https://github.com/moby/moby/issues/31101).

This only confuses people. There's no reason why docker-compose supports secrets but not configs, since both can be implemented the same way. At least are you accepting PR for this?

@Hacktivista We don't want to commit to continued support for configs once the feature starts diverging from secrets, so it'll have to stay a Swarm-exclusive feature. Sorry.

@shin- I don't understand this. Can you please explain?

Also just hit this issue. It is not obvious to me why docker-compose supports secrets but not configs. Especially for running swarm stacks locally via compose it would be nice to support this.

the docs do not make clear that this is a swarm-only feature. would it be possible to add a line saying as such?

I just fell down the same rabbit hole as everyone above ^^^

Would be nice if the docs indicated the "configs" option is only for swarm.

I don't agree on refusing to do what's right based on suppositions.

But if you're decided, come on, is that difficult to add a warning in docs?

Thanks for the feedback! Feel free to submit a PR to the docs repo

Just ran into this issue. It would be great to hear from maintainers as to why they've decided to make this choice; the referenced issue didn't really elucidate anything.

This just makes the whole thing very confusing:

Defining and using configs in compose files

Both the docker compose and docker stack commands support defining configs in a compose file. See the Compose file reference for details.

https://docs.docker.com/v17.09/engine/swarm/configs/#defining-and-using-configs-in-compose-files

It makes no sense that configs are not supported for non-swarm uses. It's a pain-in-the-hoo to make a Dockerfile just to pull in a config. :/

If configs aren't supported by docker-compose then it would be nice if the docs made that quite clear. Currently, the compose file reference features an extensive section on configs that doesn't mention anywhere that the feature is not supported by docker-compose. This means that Docker users who read the docs and decide to invest their time trying out this feature are confronted with a warning that the configs key will be ignored, and that actually "Compose does not support 'configs' configuration", which is a tad frustrating.

sorry for the late response, what is the proper way to use run time configuration( when run dockers local with docker-compose without swarm orchestration)?

@lironmo I think you're SOL. You can use a volume but volumes don't support chmod/chown AFAICT so if your service is picky about that sort of thing then I don't know what you can do.

Just hit this myself with two services where I need custom config files, one could get around by not using docker and installing the service globally as I will need it for other things but the other I can't as I need to use that service with different configuration setting.

I'm still fairly new to using docker so I'm a little confused as to how to get around this other than ditching docker and running the services outside of containers with different config files as and when required, which feels wrong.

So re-reading the above is this a fair summary

  1. You can't do this with docker-compose (non-swarm) so don't both trying
  2. You need to build a customer DockerFile that uses your custom configuration file (however you do that) then use that image within your docker-compose YML file?

As a workaround one can use docker-compose.override.yml to extend the docker-compose.yml bind mounting the config file (given it's available as local file) in the service's volume section. Still: No template-driver available though.

Simplified example:
docker-compose.override.yml

services:
  traefik:
    image: traefik:2.3
    configs:
      - source: traefik-dynamic
        target: /etc/traefik/dynamic.yml
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
configs:
  traefik-dynamic:
    file: ./dynamic.yml

docker-compose.override.yml

services:
  traefik:
    volumes:
      - ./dynamic.yml:/etc/traefik/dynamic.yml
Was this page helpful?
1 / 5 - 1 ratings