# Setup Docker Credential Helper

Today, I setup my company staging server for deploying applications. And I faced to a Docker problem: I can login to Docker Registry but I cannot pull any docker images from that.

After some hours, I found the solution, and I am sharing to you. I hope you can find this helpful solution.

  1. Basic information:

    • By default, Docker will save your password as base64 encoded string on login successfully to Docker Hub or other public/private Docker Registry.
    • To solve this problem, Docker support some credential help but you must configure it manually. (Read more: Docker Credential Store)
  2. System Information

    • OS: Ubuntu 20.04.
    • Docker: 19.03.9.
    • Docker Credential Helper: pass.
  3. Prerequisite

    • Logout of all Docker account before you move to the configuration steps. Docker will clear the saved credentials.
      docker logout {registry_url}
      
  4. Configuration Guideline

    4.1. Install pass

    sudo apt install pass -y
    

    4.2. Install docker-credential-pass

    wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.3/docker-credential-pass-v0.6.3-amd64.tar.gz
    tar -xf docker-credential-pass-v0.6.3-amd64.tar.gz
    chmod +x docker-credential-pass
    sudo mv docker-credential-pass /usr/local/bin/
    

    or one-line style

    wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.3/docker-credential-pass-v0.6.3-amd64.tar.gz && tar -xf docker-credential-pass-v0.6.3-amd64.tar.gz && chmod +x docker-credential-pass && sudo mv docker-credential-pass /usr/local/bin/
    

    You should check for the latest version from Docker Credential Helper Releases Page

    4.3. Generate a new GPG Key

    Read the GitHub Article: Generate a new GPG Key.

    After that, you will get a gpg-id like "5BB54DF1XXXXXXXXF87XXXXXXXXXXXXXX945A". Copy it to clipboard for the next step.

    4.4. Configure pass

    pass init gpg-id (get from the previous step)
    

    4.5. Use pass as docker credential store

    sed -i '0,/{/s/{/{\n\t"credsStore": "pass",/' $HOME/.docker/config.json
    

    4.6. Login to Docker Registry

    docker login -u {username} {registry_url}
    

    Then enter the password, and you should see the message likes Login Succeeded.

That 's all!

Reference link: https://github.com/docker/docker-credential-helpers/issues/102#issuecomment-388974092