Docker Login Using Pass
Docker registry have rate limits and the way to increase them is to login with your account however doing so with the default mechanism would store your password in plain text which should be avoided just as a general security practice.
In order to get around that we can use pass to serve as our credential storage and it’s corresponding docker credential helper.
Pre-requisites
- This guide assumes you have admin or root access
- You have a working docker installation
Steps
-
Generate a gpg2 key, is required by pass, to do so run:
gpg2 --full-generate-key
Follow the steps from the prompt
-
Note down the second part of the generated key with:
❯ gpg2 --list-keys --keyid-format=long /home/jorge/.gnupg/pubring.kbx ------------------------------ pub ed25519/72675FC6CA148159 2022-06-16 [SC]
In this example what we should note down is
72675FC6CA148159
-
Install pass according to your platform
-
Initialize the default Password store using the second part of the public key that you already noted down on step #2
pass init 72675FC6CA148159
-
Install the (docker credential helper)[https://github.com/docker/docker-credential-helpers/releases] for pass.
wget <url-of-helper-release> # this command may require sudo tar -C /usr/local/bin -xzf docker-credential-pass-v<newest-version>-amd64.tar.gz
-
Setup docker to use pass helper by adding this to the file
~/.docker/config.json
nano ~/.docker/config.json # update the content to have the entry: { ... "credsStore": "pass" ... }
-
Finally login with docker
docker login
Result
After this docker will be authenticated against the public docker registry which would help you to have a higher rate limit to pull/push images