Gitlab-runner user cannot log in to gitlab docker registry "Error saving credentials"

I have a shell executor that cannot log in to the gitlab docker registry because I have installed docker-credentials-helper.

echo -n $CI_REGISTRY_PASSWORD | docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY

Error saving credentials: error storing credentials - err: exit status 1, out: `pass not initialized: exit status 1: Error: password store is empty. Try "pass init".`

ERROR: Job failed: exit status 1

I have configured pass correctly for my user, but I cannot get it working for the gitlab-runner user.

If I sudo su - gitlab-runner and try to generate a gpg key for it so that I can initialise pass, I get the following error:

pg: agent_genkey failed: Permission denied
Key generation failed: Permission denied

A solution I saw was to change the password for gitlab-runner and run gpg --generate-key with sudo but that doesn’t seem like a great solution. I feel like I’ve probably done something wrong somewhere.

So: I can’t create a gpg key for gitlab-runner which means I can’t run pass init, which means it can’t use docker-credentials-pass to log in to the docker registry. Is there a solution to this, or is my entire approach completely wrong?

Thanks for any help you can give me!

gitlab-runner --version
Version:      12.8.0
Git revision: 1b659122
Git branch:   12-8-stable
GO version:   go1.13.7
Built:        2020-02-22T03:36:44+0000
OS/Arch:      linux/arm

Hi, These are exactly my thoughts. Did you ever find a solution to this problem?