nickjj / ansible-docker

Install / Configure Docker and Docker Compose using Ansible.
MIT License
750 stars 224 forks source link

Avoid docker login issue with X11 #104

Closed coute closed 3 years ago

coute commented 3 years ago

Hello @nickjj, I encountered an issue with the docker login command after i have installed docker with your role. I got the message : Error saving credentials: error storing credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY` According to this post : https://github.com/docker/compose/issues/6023#issuecomment-419792269 the fix consist into installing the "pass" package. I tried it and it worked. You should envisage to add this package in default docker__package_dependencies list to avoid this issue.

nickjj commented 3 years ago

Hi,

Which OS / distro is this affecting?

Also pass is a command line password manager that uses GPG keys to handle encrypting and decrypting passwords.

The issue hints that this is only maybe related to installing Docker Compose from your distro's repos with apt, but this role doesn't do that. Docker Compose is installed through pip.

Did you install Docker and / or Docker Compose through your distro's repos before using this role?

coute commented 3 years ago

The issue was with Debian buster. I installed docker and docker compose with the role only.

coute commented 3 years ago

I had an other problem with registries. I used the docker__registries variable to set a private registry. The roles is set with become: yes

I launched the playbook and the docker-login task worked. But docker credentials that is stored in .docker folder is only root accessible.

ls -lha /home/ansible/.docker/
total 12K
drwxr-xr-x 2 root    root    4.0K Jan 22 17:36 .
drwxr-xr-x 6 ansible ansible 4.0K Jan 22 17:36 ..
-rw------- 1 root    root     142 Jan 22 17:36 config.json

So the docker login command doesn't work after the installation with the ansible user.

coute commented 3 years ago

I had an other problem with registries. I used the docker__registries variable to set a private registry. The roles is set with become: yes

I launched the playbook and the docker-login task worked. But docker credentials that is stored in .docker folder is only root accessible.

ls -lha /home/ansible/.docker/
total 12K
drwxr-xr-x 2 root    root    4.0K Jan 22 17:36 .
drwxr-xr-x 6 ansible ansible 4.0K Jan 22 17:36 ..
-rw------- 1 root    root     142 Jan 22 17:36 config.json

So the docker login command doesn't work after the installation with the ansible user.

I used become_flags: "-i" in playbook to fix the issue. The .docker folder has been created in root home folder.

nickjj commented 3 years ago

Which Buster ISO are you using, or cloud hosting provider if you can't pick it?

coute commented 3 years ago

AWS buster

nickjj commented 3 years ago

Can you link me to the exact AMI you're using?

coute commented 3 years ago

https://aws.amazon.com/marketplace/pp/B0859NK4HC?ref=cns_srchrow

nickjj commented 3 years ago

The X11 issue seems related to that specific ISO of Debian. I can't reproduce it on a few other cloud vendor's versions of Debian or what comes with Vagrant's Debian box or Docker's variant of Debian.

coute commented 3 years ago

I have made some tests on a Vagrant host with a buster image. I found that a previous role in my playbook install python3-docker package with apt. This package depends on golang-docker-credential-helpers If I remove both of them, that fix the issue. My bad.

nickjj commented 3 years ago

Ok, so it sounds like the X11 issue is resolved without any changes to this role due to the issue you linked having resolutions available by not having a previous version of Docker / Docker Compose installed.

Going to close this.

The file permission issue with the login credentials is a separate issue and I'm working on a patch for that.