I'm fiddling arround with docker login using the "secretservice" in a testautomation like so:
wget -O docker-credential-secretservice https://github.com/docker/docker-credential-helpers/releases/download/v0.8.0/docker-credential-secretservice-v0.8.0.linux-amd64
chmod +x docker-credential-secretservice
sudo mv docker-credential-secretservice /usr/local/bin/
sudo apt install -y libsecret-1-0
systemd-machine-id-setup --print
mkdir -p ~/.docker
cat <<EOT >> ~/.docker/config.json
{
"credsStore": "secretservice"
}
EOT
But when the login happens via echo $GITHUB_TOKEN | docker login ghcr.io -u <myuser> --password-stdin
it fails with:
Error saving credentials: error storing credentials - err: exit status 1, out: `Could not connect: No such file or directory`
P.S.: Running on windows-2022 in a wsl2 distro: Ubuntu-22.04
The problem was the missing gnome-keyring
. Installation:
apt-get update
apt-get install -y gnome-keyring
And after a restart of the wsl
the docker-credential-secretservice
was running.
Verification via docker-credential-secretservice list
returns {}
, which is a valid empty list.
If you are on a interactive wsl
you can create a keyring or if you not already have one you will be forced to do so by docker login
by a little popup dialog.
In my case, during test automation I have to do it in a non-interactive and headless way.
So the second part to get the problem solved is to create a dbus-run-session
and pass the actions that need the login via script including the creation of a keyring.
dbus-run-session -- ./pull-docker.sh
and the pull-docker.sh
contains:
#! /bin/bash
echo '$USER' | gnome-keyring-daemon --unlock
echo $GITHUB_TOKEN | docker login ghcr.io -u <your docker registry user> --password-stdin
docker compose pull