Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-credential-pass has wrong $HOME directory when running docker with sudo #212

Open
willburden opened this issue Nov 13, 2021 · 2 comments

Comments

@willburden
Copy link

I'm not overly familiar with this repo, but I've just wrestled with docker-credential-pass for an hour and now I've figured out the problem it seems quite fixable.

The error is this: Error saving credentials: error storing credentials - err: exit status 1, out: pass store is uninitialized.

Here's how this problem can occur:

  1. The user initialises their pass store with pass init, creating the ~/.password-store directory.
  2. They download docker-credential-pass and add it to their $PATH.
  3. They attempt to login with sudo docker login (not using sudo would cause permission errors).
  4. The login succeeds but with the above error - their credentials haven't been saved, and it claims pass store is uninitialized even though it definitely is.

The cause is that, in some configurations of Linux, the root user has a different ~ (home directory) to the normal user. This means docker-credential-pass is looking in the wrong place for the pass store; on my machine I believe it was looking in /root/.password-store. I fixed this on my own machine by editing /etc/sudoers so that the root user keeps the $HOME env variable of the normal user, but it seems that the program could be edited in some way to avoid this requirement altogether, or at least to provide a more useful error message. If I was familiar with Go I would attempt to make this change myself.

Note: this may be the cause of issue #140 , I'm not sure.

@animeshn99
Copy link

Hi @willburden , You can use "docker login" command. Just you need to add the current user to the docker group so it wont have any permission errors by running the below one line.
sudo usermod -aG docker $USER
then close and open the terminal

@animeshn99
Copy link

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants