Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configs now work without swarm? #8707

Closed
l3s2d opened this issue Sep 29, 2021 · 10 comments
Closed

Configs now work without swarm? #8707

l3s2d opened this issue Sep 29, 2021 · 10 comments

Comments

@l3s2d
Copy link

l3s2d commented Sep 29, 2021

It looks like configs are working without swarm (mabye secrets too?). I didn't see anything in the changelogs describing this.

There's no mention of swarm in the docs now either: https://docs.docker.com/compose/compose-file/compose-file-v3/#configs-configuration-reference

This is a welcome change, but I want to confirm, is this behavior intended and should we depend on it?

Related issues:

@ndeloof
Copy link
Contributor

ndeloof commented Sep 30, 2021

swarm is not required nor supported, Compose V2 is for "standalone" docker engine.
sounds like a bug then

@ndeloof
Copy link
Contributor

ndeloof commented Sep 30, 2021

ran a quick test:

services:
  test:
    image: alpine
    command: cat /my_config
    configs:
      - my_config

configs:
  my_config:
    file: ./config_data
$ echo "hello world" > config_data 
$ docker compose up
[+] Running 1/0
 ⠿ Container truc-test-1  Created                                                                                                                  0.0s
Attaching to truc-test-1
truc-test-1  | hello world
truc-test-1 exited with code 0

Please better describe your issue

@ljani
Copy link

ljani commented Jan 18, 2022

Oh, this is great news. I was under the impression that only Swarm Mode supported them as well. Things have changed in v2 then I guess.

However, it would be nice if it didn't use bind mounts as described in related issues, and one could use them with a remote server:

ljanitest> echo "hello world" > config_data
ljanitest> docker-compose-v2 up
[+] Running 0/0
- Container ljanitest_test_1 Recreate 0.0s
Error response from daemon: invalid mount config for type "bind": invalid mount path: 'C:/devel/ljanitest/config_data' mount path must be absolute

EDIT: for the reference, v1:

ljanitest> docker-compose-v1 up
WARNING: Some services (test) use the 'configs' key, which will be ignored. Compose does not support 'configs' configuration - use `docker stack deploy` to deploy to a swarm.
Docker Compose is now in the Docker CLI, try `docker compose up`
Starting c4923addfd9b_ljanitest_test_1 ... done
Attaching to c4923addfd9b_ljanitest_test_1
c4923addfd9b_ljanitest_test_1 | cat: can't open '/my_config': No such file or directory
c4923addfd9b_ljanitest_test_1 exited with code 1

@gauthierl
Copy link

I'm very happy to see this feature available in docker-compose without swarm !

I'd really like to use some Golang templates to generate config files based on environment variables (and get ride of my python script that do exactly the same).

However, I would also like to have a confirmation that this feature is not a bug and that we can rely on it not only today but also in the future.

The docker documentation have still a note that say that they only available in Swarm : https://docs.docker.com/engine/swarm/configs/#about-configs

@gauthierl
Copy link

After a try, it seem that template_driver (TemplateDriver) is ignored. The container bind mount the template file on destination without interpret it.

Will that be supported in the future ?

@nathanweeks
Copy link

However, I would also like to have a confirmation that this feature is not a bug and that we can rely on it not only today but also in the future.

The docker documentation have still a note that say that they only available in Swarm : https://docs.docker.com/engine/swarm/configs/#about-configs

@gauthierl Configs are documented in the Compose spec, so it seems they should continue to be supported in Docker Compose V2?

@ndeloof
Copy link
Contributor

ndeloof commented Feb 24, 2022

docker-compose, both v1 and v2, support config by use of a bind mount. Docker engine without swarm has no support for secrets or configs, and so this is the only available option (designed for development mode).

@ndeloof ndeloof closed this as completed Feb 24, 2022
@nathanweeks
Copy link

docker-compose, both v1 and v2, support config by use of a bind mount. Docker engine without swarm has no support for secrets or configs, and so this is the only available option (designed for development mode).

Thanks for the clarification. It would be really convenient for production (or any use of a remote Docker Engine) if Docker Compose could somehow work around this; e.g., creating an anonymous volume, copying a specified config/secret file to the volume, and (somehow) mount just the file from the volume at the specified path in the service container. I'm happy to submit an issue if a similar feature request hasn't already been discussed and shot down :-)

@gauthierl
Copy link

Thanks for the clarification @ndeloof !

I'm agree with @nathanweeks it would be an interesting feature :)

But, I would also understand that it's over the scope of what compose should do.
It's something that should probably be implemented directly in Docker Engine.

@ndeloof
Copy link
Contributor

ndeloof commented Feb 24, 2022

Being able to create a volume with some initial content is an interesting idea. Could maybe be feasible with some volume driver options? Anyway, this is not limited to config/secrets, which only make sense when the actual engine has support for such concepts (the way it was introduced in docker-compose is only a hack for smooth local developer experience while targeting swarm for production)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants