To run Docker directly on WSL2 without using Docker desktop I followed different sources. The steps I performed are very similar to those describe here: https://dev.to/felipecrs/simply-run-docker-on-wsl2-3o8. Docker works, but I still had to configured a credential store so a docker login would work. I tried two approaches:
A) I tried to use pass as credential store following https://github.com/docker/docker-credential-helpers/issues/102#issuecomment-388974092
'docker login'.... Login Succeeded
. The auths were added to .docker/config.json, where the credsStore was set to 'pass'. However, after the successful docker login, the pull command still fails with an authentication error: Error response from daemon: unauthorized: unauthorized to access repository:...
It seems like the token is not used for the subsequent command anymore.
B) Trying a less desirable approach, I switched to configuring wincred.exe as credsStore
~/.docker/config.json
{
"credsStore": "wincred.exe"
}
as shown in the Bonus section at the bottom here: https://dev.to/felipecrs/simply-run-docker-on-wsl2-3o8:
wincred_version=$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/docker-credential-helpers/releases/latest | xargs basename)
sudo curl -fL "https://github.com/docker/docker-credential-helpers/releases/download/${wincred_version}/docker-credential-wincred-${wincred_version}-$(dpkg
--print-architecture).zip" | zcat | sudo tee /usr/local/bin/docker-credential-wincred.exe >/dev/null
sudo chmod x /usr/local/bin/docker-credential-wincred.exe
This approach works, but strangely every login or pull takes > 1min before the authentication passes successfully and the operation starts.
I would prefer to have a clean Linux-only approach similar to A, but would also be grateful for an explanation / solution to the remaining issue with B.
CodePudding user response:
Since you're using pass
, that means that you needed a GPG key to encrypt the credential store for Docker.
Does your GPG key have a passphrase? Maybe it's trying to request for it but it doesn't know which terminal to use. For encrypting your credentials the passphrase isn't required, since it uses the public-key (so docker login
won't cause any error) but for decryption it requires the private-key, so it will fail if it isn't able to ask you for the passphrase.
Try setting the GPG_TTY
in WSL2 to the one that you're currently using for the Docker pull:
export GPG_TTY=$(tty)