Docker build fails after successful docker login with ERROR: error getting credentials

I am on Ubuntu 24.04.1 LTS.
logged in as a user that is in group ‘docker’
The command ‘docker login -u DOCKERID’ is successful.
config.json has only a few lines:

{
   "auths": {
      "https://index.docker.io/v1/": {}
   },
   "credsStore": "pass"
}

As you can see, pass is used to store credentials.
‘pass ls’ after the ‘docker login’ shows:

Password Store
└── docker-credential-helpers
   └── aHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEv
      └── DOCKERID

so all looks fine.
Then a docker build with a valid docker file (tested without docker login and works fine) gives the error:

#2 [internal] load metadata for docker.io/library/ubuntu:24.04
#2 ERROR: error getting credentials - err: exit status 1, out: `exit status 2: gpg: public key decryption failed: No such file or directory
gpg: decryption failed: No such file or directory

why??

Thanks,
Marcus

Is it Docker CE or Docker Desktop? Because Docker Desktop is not supported on Ubuntu 24.04 yet.

I use Docker CE.
I tried the Docker Desktop, had too many issues and uninstalled it.

I ran an Ubuntu 24.04 virtual machine. Configured Docker CE 27.0.2 and it works. How exactly did you install Docker CE? And what did you do to configure pass?

What you see in the output of pass ls is just a file hierarchy. The GPG file should be here:

$HOME/.password-store/docker-credential-helpers/aHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEv/DOCKERID.gpg

Change the DOCKERID to your actual Docker ID

Check if the file is there.

Also check this command:

pass show docker-credential-helpers/aHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEv/DOCKERID

Change DOCKERID to you actual Docker ID.

It should ask for a passphrase that you set when initialized the password store and it will decrypt the file and return the password.

the GPG file and pass command are as you described.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/trusted.gpg.d/docker.asc
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu noble stable" >> /etc/apt/sources.list.d/docker.list
apt update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Have you checked the logs of the docker service? You could also enable debug logs if the normla level is not enough.

Could you also answer this question as well?

For example did you initialized pass with the GPG id as argument?