# community.docker.docker\_login issue

**URL:** <https://forum.ansible.com/t/community-docker-docker-login-issue/38169>\
**Category:** Ansible Project\
**Created:** [June 28, 2023, 8:29pm UTC](https://forum.ansible.com/t/community-docker-docker-login-issue/38169 "2023-06-28T20:29:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamflow](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@williamflow](https://forum.ansible.com/u/williamflow)\
**Post date:** [June 28, 2023, 8:29pm UTC](https://forum.ansible.com/t/community-docker-docker-login-issue/38169/1 "2023-06-28T20:29:28Z")

</div>

so bottom line I am using the community.docker collection and my code is pretty simple to start I just want to login to my registry and i am failing and do not have  
a clue as to why my code is below and I get this error

{  
“msg”: “Error connecting: Error while fetching server API version: (‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))”,  
“invocation”: {  
“module\_args”: {  
“registry\_url”: “[registry.hub.docker.com](http://registry.hub.docker.com)”,  
“username”: “xxxxxxxxx”,  
“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“reauthorize”: true,  
“docker\_host”: “unix://var/run/docker.sock”,  
“api\_version”: “auto”,  
“timeout”: 60,  
“tls”: false,  
“use\_ssh\_client”: false,  
“validate\_certs”: false,  
“debug”: false,  
“state”: “present”,  
“config\_path”: “/root/.docker/config.json”,  
“tls\_hostname”: null,  
“ca\_cert”: null,  
“client\_cert”: null,  
“client\_key”: null,  
“ssl\_version”: null  
}  
},  
“\_ansible\_no\_log”: null,  
“changed”: false  
}

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [June 28, 2023, 8:36pm UTC](https://forum.ansible.com/t/community-docker-docker-login-issue/38169/2 "2023-06-28T20:36:14Z")

</div>

The default url is correct, why are you setting it to that address?

from [https://docs.ansible.com/ansible/latest/collections/community/docker/docker\_login\_module.html](https://docs.ansible.com/ansible/latest/collections/community/docker/docker_login_module.html)

registry\_url string The registry URL. Default: “[https://index.docker.io/v1/](https://index.docker.io/v1/)”

via CLI  
$ docker info | grep Registry  
Registry: [https://index.docker.io/v1/](https://index.docker.io/v1/)

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [June 28, 2023, 8:40pm UTC](https://forum.ansible.com/t/community-docker-docker-login-issue/38169/3 "2023-06-28T20:40:10Z")

</div>

Hi William,

> so bottom line I am using the community.docker collection and my code  
> is pretty simple to start I just want to login to my registry and i  
> am failing and do not have  
> a clue as to why my code is below and I get this error
> 
> {  
> &nbsp;&nbsp;"msg": "Error connecting: Error while fetching server API version:  
> ('Connection aborted.', FileNotFoundError(2, 'No such file or  
> directory'))", "invocation": {

the error says that the module cannot talk to your Docker daemon.

You didn't configure any way to talk to the Daemon, so the default is  
used, which means using a Unix socket /var/run/docker.sock.

When trying to access /var/run/docker.sock, a FileNotFoundError error  
was raised.

You can probably resolve this by telling the module how to connect to  
your Docker daemon. (The most easy way to do that is to use the  
community.docker.docker module defaults group, then you only have to do  
it once for all modules in your play. Alternatively you can use  
environment variables, which should work fine for localhost - it's more  
tricky on remote hosts.)

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![williamflow](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@williamflow](https://forum.ansible.com/u/williamflow)\
**Post date:** [June 28, 2023, 9:15pm UTC](https://forum.ansible.com/t/community-docker-docker-login-issue/38169/4 "2023-06-28T21:15:02Z")

</div>

Ok that worked but I now keep getting a new error when I go to task 2:

- name: run command  
community.docker.docker\_container\_exec:  
container: ubuntu  
command: /bin/bash -c “ls -lah”  
chdir: /root  
register: result

- name: Print stdout  
debug:  
msg: ‘{{result}}’

I get this:  
fatal: [localhost]: FAILED! =\> {“changed”: false, “msg”: “Could not find container "ubuntu"”}

am i suppose to pull it not sure here

Thanks

Bill

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [June 29, 2023, 4:45am UTC](https://forum.ansible.com/t/community-docker-docker-login-issue/38169/5 "2023-06-29T04:45:47Z")

</div>

Hi,

does `docker container list` show a container with name `ubuntu`? If  
not, the error message is completely accurate. The  
docker\_container\_exec module does something similar to `docker exec -w  
/root ubuntu /bin/bash -c "ls -lah"`.

If you don't have a container called `ubuntu`, you first have to start  
one so you can run a command in it. Or alternative, use the  
docker\_container module to create a new container and run that command  
directly in it (with `detach: false`).

Cheers,  
Felix
