Unable to combine docker_login with credential store

Hello, I’m using ansible 2.9 to install Docker on a remote RedHat, create a docker credential store with pass and pull several images from private docker registries.
After the run of my playbook installing docker, docker credential store, etc. I remove the config.json of the .docker directory so it will re-initialize during the next docker login.

After this I use following ansible task to make a docker login:

`

  • name: Logon
    docker_login:
    registry: my-private-registry.on.my.internal.site
    username: myaccount
    password: “{{passwordvar}}”
    become: yes
    `

This fails because it generates plain text content in my config.json.
{ "auths": { "my-private-registroy.on.my.internal.site": { "auth": "U9ZjQWNjdC10cmF4LAJuZC1jaTpBKzVyWFYwSF8tNnEqcTkf", "email": null } } }

When I remove manually the config.json file and use the docker login command on the server itself, I get what I wanted.

{ "auths": { "my-private-registroy.on.my.internal.site": {} }, "HttpHeaders": { "User-Agent": "Docker-Client/19.03.6 (linux)" }, "credsStore": "pass" }

Why is it not working with my ansible task?

Hi,

docker_login will only support credential stores in Ansible 2.10 (see
https://github.com/ansible/ansible/pull/63158).

You can try to use the new version of the module
(https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/docker/docker_login.py)
with Ansible 2.9 if you need support for that now.

Cheers,
Felix