171
OS: Ubuntu 18.04 Server
Docker 18.3 CE

I am logged onto the server, from my Windows 10 laptop, using a PuTTY SSH session.

I don't have Docker on my local Windows laptop, so all the work is done on the remote server.

I can execute all Docker commands, on the remote server, using the terminal session.

However, when I try to save my image to the Docker hub, when I try to login, using:

docker login

I get the following error message:

error getting credentials - err: exit status 1, out: `GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files`

I did not get any error messages, when I created my image on the remote server.

I also do not see a .docker folder in the related home directory on the remote server. Any ideas?

Gajanan Kulkarni
  • 697
  • 6
  • 22
EastsideDev
  • 6,257
  • 9
  • 59
  • 116
  • I ran into a somewhat similar problem today while trying to run `docker login` from within a LXD/LXC container. That particular one I solved by copying `.docker/config.json` from my host over to my `$HOME/.docker/` directory within the LXD/LXC container, which I created manually. I'm currently trying to figure out another issue now, but wanted to ask if you had you tried doing this yet? – code_dredd May 09 '18 at 22:07
  • No, I sort of gave up on Windows. I am getting a new laptop tomorrow, where I will be installing Ubuntu 18 as a dual boot. – EastsideDev May 09 '18 at 22:12
  • I have opened up an issue for this here https://github.com/docker/cli/issues/1136. If they find a solution for this, I'll post it here. – thishandp7 Jun 21 '18 at 09:26

23 Answers23

320

Edit 2019-04-07:

As this is the currently selected answer, I think people should try @Anish Varghese solution below first as it seems to be the easiest. You only need to install the gnupg2 and pass packages:

sudo apt install gnupg2 pass

If it doesn't work, then you can try my original solution here:

I had the same issue. bak2trak answer worked, but it saved credentials in clear text. Here's the solution if you want to keep them in a password store.

1) Download docker-credential-pass from https://github.com/docker/docker-credential-helpers/releases

2) tar -xvf docker-credential-pass.tar.gz

3) chmod u+x docker-credential-pass

4) mv docker-credential-pass /usr/bin

5) You will need to setup docker-credential-pass (following steps are based of https://github.com/docker/docker-credential-helpers/issues/102#issuecomment-388634452)

5.1) install gpg and pass (apt-get install gpg pass)

5.2) gpg --generate-key, enter your information. You should see something like this:

pub   rsa3072 2018-10-07 [SC] [expires: 2020-10-06]
      1234567890ABCDEF1234567890ABCDEF12345678

Copy the 123... line

5.3) pass init 1234567890ABCDEF1234567890ABCDEF12345678 (paste)

5.4) pass insert docker-credential-helpers/docker-pass-initialized-check and set the next password "pass is initialized" (without quotes).

5.5) pass show docker-credential-helpers/docker-pass-initialized-check. You should see pass is initialized.

5.6) docker-credential-pass list

6) create a ~/.docker/config.json with:

{
"credsStore": "pass"
}

7) docker login should now work

Note: If you get the error "pass store is uninitialized" in future run, run the below command (it will reload the pass store in memory):

pass show docker-credential-helpers/docker-pass-initialized-check

It will ask your password and it will initialize the pass store.

This is based off this discussion: https://github.com/moby/moby/issues/25169#issuecomment-431129898

Jean-Philippe Jodoin
  • 4,536
  • 1
  • 25
  • 28
  • 1
    Didn't work for me. I get the message when I try docker login: "error getting credentials - err: exit status 1, out: `pass store is uninitialized" – GlacialSpoon Oct 29 '18 at 13:02
  • I started again after uninstalling pass and deleting the .password-store folder. Seems better now. Thanks. – GlacialSpoon Oct 29 '18 at 13:43
  • @GlacialSpoon: Before calling docker login, you can try to call pass show docker-credential-helpers/docker-pass-initialized-check, it wil lask you for your password and it should be initialized. – Jean-Philippe Jodoin Oct 30 '18 at 00:26
  • 3
    @Jean-Phillipe Jodoin, thanks. It seems I have to call this periodically otherwise the login call fails to find the credentials. I read this might be something to do with the gpg cache expiring and the "pass show" wakes it up. When the server reboots I have to go back to the "pass insert" step before things work. It's not very convenient but it is allowing me to proceed. – GlacialSpoon Oct 30 '18 at 15:08
  • 2
    Check the answer by Anish Varghese below, it seems to be the easiest and cleanest solution. – Aurelien Nov 22 '18 at 02:58
  • gpg: invalid option "--generate-key" – Calimo Mar 26 '19 at 13:25
  • Can you make it more clear which values we should be changing and which we shouldn't? – Joe Phillips Apr 06 '19 at 19:32
  • Due to the answer below, this one is actually harmful at this point. It will actually keep the one below from working properly. I feel like it would be a good netizenship move to instruct people to first try the answer below – Joe Phillips Apr 06 '19 at 21:26
  • 1
    @JoePhillips: Agreed with you. Integrated his solution with citation. – Jean-Philippe Jodoin Apr 07 '19 at 12:01
  • I need to also follow this post: https://www.bountysource.com/issues/61064500-docker-credential-pass-does-not-work-at-all , because I was getting a StoreError('Credentials store docker-credential-pass exited with "exit status 2: gpg: decryption failed: No secret key".',) after doing a docker pull. Therefore, performing a export GPG_TTY=$(tty) – MFAL Feb 11 '20 at 12:38
  • Why did installing gnupg works? Without it I had to wait about 10s till login prompt, after everything seem to start instantaneously – Igor Tiulkanov Aug 15 '20 at 07:36
292

Install the following Packages in ubuntu fixed my issue

sudo apt install gnupg2 pass
Ghasem
  • 14,455
  • 21
  • 138
  • 171
Anish Varghese
  • 3,450
  • 5
  • 15
  • 25
53

I faced the same issue in ubuntu 18.08 and this finally worked for me.. as a temporary solution.

I had created this folder home/.docker/ as some solutions suggested me to create a file config.json and write default credentials in it i.e.

{
    "credsStore": "pass"
}
  • I deleted this file config.json.
  • Then renamed docker-credential-secretservice to something else so that it doesn't picks up this file.

    sudo mv /usr/bin/docker-credential-secretservice /usr/bin/docker-credential-secretservice_x

and it worked!

bak2trak
  • 1,062
  • 8
  • 11
  • 2
    @Renrhaf First [docker](https://docs.docker.com/engine/reference/commandline/login/#credentials-store) by default looks for "pass" where it searches in gnome key-chain and osx-keychain in OS-X . If it's not found then looks for `org.freedesktop.secrets`. Its not found for ubuntu 18 (some issues). After renaming it (docker-credential-secretservice) to something else then it falls back to create config file by itself, You can look in home/.docker folder one config.json file would have been created. – bak2trak May 29 '18 at 05:08
  • 1
    I just encountered this issue and solved it via this method - kind of. I installed `docker-credential-secretservice` from GH, created a `~/.docker/config.json` with content as above then tried to log in. Got an error. Then deleted the `.docker` folder, `config.json` and the `/usr/bin/docker-credential-secretservice` executable and then ran `docker login` again with success – Andy Jul 06 '18 at 06:25
  • 2
    To anyone having the same issue: Don't forget to **delete config.json** . I almost gave up on this, but it worked in the last moment, after I deleted config.json. – sr9yar Aug 13 '18 at 19:39
  • 2
    For me, I uninstalled `docker-compose` and then ran your `sudo mv /usr/bin/docker-credential-secretservice /usr/bin/docker-credential-secretservice_x` rename, it worked. Does anyone know what `docker-credential-secretservice` is used for? – WSBT Sep 07 '18 at 21:14
  • docker credential store https://docs.docker.com/engine/reference/commandline/login/#credentials-store – jhrabi Sep 19 '18 at 16:23
  • 1
    This solution worked for me, but it saves credentials base 64 encoded. I posted below a solution which uses pass. https://stackoverflow.com/questions/50151833/cannot-login-to-docker-account/52881198#52881198 – Jean-Philippe Jodoin Oct 18 '18 at 19:29
  • it works with 'mv /usr/bin/docker-credential-secretservice /usr/bin/docker-credential-secretservice_x' – Victor Nazarov Nov 13 '19 at 23:19
  • This solution worked for me in Linux mint 19.3. – Stan Jan 17 '21 at 03:47
16

This work for me in my Ubuntu 18:

docker logout
mv ~/.docker/config.json ~/.docker/config_old.json
docker login
AleSB
  • 161
  • 1
  • 3
10

I just deleted the ~/.docker/config.json and try the login again. It works. A new file is created.

Tiago Nogueira
  • 316
  • 2
  • 10
9

This may help too, at least it did in Ubuntu 20.04:

wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.3/docker-credential-secretservice-v0.6.3-amd64.tar.gz && tar -xf docker-credential-secretservice-v0.6.3-amd64.tar.gz && chmod +x docker-credential-secretservice && mv docker-credential-secretservice /usr/local/bin/

https://hackernoon.com/getting-rid-of-docker-plain-text-credentials-88309e07640d  https://github.com/docker/docker-credential-helpers/releases

Vlax
  • 1,447
  • 1
  • 18
  • 24
7

If apt install gnupg2 pass does not work for you, you can also install golang-docker-credential-helpers package

Juanra
  • 8,532
  • 2
  • 15
  • 12
7

I had this problem (headless Ubuntu 20, upgraded from 16,18) and none of the other answers worked for me. Finally, after reading some of the discussions posted here I found the problem was that the gnome-keyring was installed but not working properly. Since this was a headless, the correct answer was to remove gnome-keyring (since it was providing the org.freedesktop.secrets service) and then it worked perfectly.

sudo apt remove gnome-keyring golang-docker-credential-helpers
briandrawert
  • 111
  • 1
  • 2
  • Thanks. Removing gnome-keyring was enough - removing golang-docker-credential-helpers would mean to remove docker-compose, too. – Michael2 Dec 04 '21 at 20:30
6

For me the simplest solution was to create config.json file under .docker directory inside user home directory:

/home/.docker/config.json

Then i copied the content of this file from the server from where i was able to login to the docker hub.

{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "SOMEVALUE"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.06.1-ce (linux)"
        }

}

Its a easy workaround, because it doesn't require you to install or update any package which we can't do easily on production servers.

Mr Kashyap
  • 562
  • 1
  • 5
  • 16
5

Simple solution: just remove "credsStore": "secretservice" from ~/.docker/config.json

MxWild
  • 3,080
  • 2
  • 14
  • 15
5

The problem for me were solved by running the script with sudo!

sudo docker login -u YOU-USERNAME
  • --ignore-depends=golang-docker-credential-helpers golang-docker-credential-helpers this should be run before this command to work – smrf Nov 24 '21 at 19:48
3

For me docker push failed with

denied: requested access to the resource is denied

... so I wanted to docker login but got the following after entering credentials:

Remote error from secret service:
  org.freedesktop.DBus.Error.UnknownMethod:
  No such interface 'org.freedesktop.Secret.Collection' on object at path
  /org/freedesktop/secrets/collection/login

Error saving credentials:
  error storing credentials - err: exit status 1, out:
  No such interface 'org.freedesktop.Secret.Collection' on object at path
  /org/freedesktop/secrets/collection/login

Luckily, I had another machine available on which I was able to log in without any changes to the system. I copied the content of ~/.docker/config.json...

{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "<some-hash-value>"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.09.2 (linux)"
        }
}

... to the other machine and docker push worked.

CodeManX
  • 11,159
  • 5
  • 49
  • 70
2

Just Try it: sudo apt install golang-docker-credential-helpers

  • One earlier answer already mentions this installation. What information does your answer add ? – XouDo May 06 '21 at 10:41
1

Well you already read solution but the fact is gnupg2 is now not installed by default in Ubuntu 18+, That is the reason sometime after apt upgrade , things behave a little differently.

octamois
  • 11
  • 1
  • 3
1

Following the answer I had the several issues.

  1. The key generation was stuck at entropy (step 5.2).

Fortunately, the fix is easy and you only need to install the package rng-tools: https://stackoverflow.com/a/32941065

  1. On pass init <key> (step 5.3) the error gpg: decryption failed: No secret key showed up.

In fact this issue is due to the secret key being restricted to root privileges.

I changed the ownership of the .gnupg .password-store folders in my user's homedir.

Then reloaded the dirmngr to avoid "unsafe ownership" warning:

gpgconf --kill dirmngr

If you don't want to do all that you can run all commands of the answer as root/sudo.

v0id
  • 21
  • 1
  • 3
1

To me Ubuntu 20.04

sudo apt install golang-docker-credential-helpers

It is working

Kyuhwan Yeon
  • 151
  • 2
  • 8
0

You don't have a credentials store. Try using Gnome Keyring; depending on your linux installation, it might already be installed. You can use GK to securely store auth data in Chrom{e,ium} (and probably more) too. Getting back to Docker, you'd need a .docker/config.json like:

{
    "credsStore": "secretservice"
}

Then, make sure you've configured PAM to unlock the keyring: https://wiki.archlinux.org/index.php/GNOME/Keyring#PAM_method

Nate Symer
  • 2,185
  • 1
  • 20
  • 27
0

sudo apt install gnupg2 pass wasn't working for me and I was using docker without adding sudo in front everytime. So I added sudo docker login -u <myusername> it prompted me the pass and this time it worked since I used sudo for my docker.

Ameer Ul Islam
  • 380
  • 3
  • 5
0

If you somehow still stuck in this issue, try:

sudo docker login <site>
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
-1

For me, uninstalling the package docker-compose and manually installing a more recent version solved the issue.

Uninstalled docker-compose :

sudo apt remove docker-compose

Installed more recent version as indicated here https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-debian-10 :

sudo curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Redgis
  • 69
  • 1
  • 1
  • 7
-2

creating the following solved it for me:

AWS_CONFIG=$AWS_DIR/config
AWS_CREDENTIALS=$AWS_DIR/credentials
mkdir -p $AWS_DIR
Danletski
  • 1
  • 3
-2

In my case, this error was resolved after giving read and write access to all users to the file /var/run/docker.sock:

sudo chmod 666 /var/run/docker.sock
-3

Install the following Packages in ubuntu

sudo apt install gnupg2 pass

This is worked for me.