How can I use docker_secrets in docker_container?

160 views
Skip to first unread message

ansiblehuhn

unread,
Apr 9, 2021, 9:10:54 AM4/9/21
to Ansible Project
Hi,

is there a way I can use docker_secrets within docker_container?
If this is not possible maybe someone could help me with this:
I want to configure the initial admin-password of a container. Therefore I can use a mounted file in the container (for example docker secret) or an encrypted string (htpasswd) as a command argument. I only want to store the plain password in the ansible vault, not the encrypted version or an additional file on disk.

Thanks for your help :)

Felix Fontein

unread,
Apr 11, 2021, 9:38:15 AM4/11/21
to ansible...@googlegroups.com
Hi,

I'm not sure this is possible at all.

docker_secret is a module for Docker's swarm mode. docker_container is
a module for Docker's non-swarm mode. If you use docker_swarm_service
to manage a Docker swarm service, you can specify the secrets to use.

I also cannot find any reference to secrets when looking at the `docker
run` help (which uses the same APIs as the docker_container module
does).

Cheers,
Felix

Fettheit

unread,
Apr 11, 2021, 1:35:59 PM4/11/21
to ansible...@googlegroups.com
Surely not best practice, but with Portainer I could use secrets in my local stack without being in a Swarm-Cluster. It works great and I thought it would be nice to recreate my stack in Ansible to go a step further to automate additional tasks outside Docker-compose

> Am 11.04.2021 um 15:38 schrieb 'Felix Fontein' via Ansible Project <ansible...@googlegroups.com>:
>
> Hi,
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20210411153759.5f054672%40rovaniemi.
Reply all
Reply to author
Forward
0 new messages