GitHub - Resolving Error response from daemon: Head : unauthorized
Problem Statement
You get an unathorized error when trying to pull an image from GitHub.
This generally happens because you either don't have a GitHub token set up, or your token doesn't have the right permissions.
Install and setup the GitHub CLI
While you can setup a GitHub token manually by going to https://github.com/settings/tokens?type=beta, I prefer to just use the gh auth token
feature of the GitHub CLI.
Setup GitHub CLI
- Install the GitHub CLI using the instructions here.
- Login using
github auth login
and follow the instructions in your terminal to authenticate in your browser using the one-time code that will appear - Verify you're successfully logged in with
gh auth status
. You should see something like:➜ gh auth status github.com ✓ Logged in to github.com account mbuotidem (keyring) \- Active account: true \- Git operations protocol: ssh \- Token: gho_************************************ \- Token scopes: 'admin:public_key', 'gist', 'read:org', 'repo'
Grant yourself the packages read scope
- Run
gh auth refresh
passing in the desired scope. Follow the instructions in your terminal to authenticate in your browser using the one-time code that will appear
Docker login and try to pull again
- Pipe the auth token into the docker login command - make sure to replace
mbuotidem
with your GitHub username|
- You can now pull the image
If you need to grant yourself other scopes, learn more about available scopes here To learn more about available GitHub CLI commands, go here