All Articles

Github Docker Packages Username Fix

I just found out that Github offers free docker repositories and I was excited to try it out for my Burn After Reading project but ran into a snag, as my username is non-lowercase (Tethik).

The instructions say to do as follows, which seems pretty straight forward.

# Step 1: Authenticate
$ docker login docker.pkg.github.com --username Tethik

# Step 2: Tag
$ docker tag IMAGE_ID docker.pkg.github.com/Tethik/burn-after-reading/IMAGE_NAME:VERSION

# Step 3: Publish
$ docker push docker.pkg.github.com/Tethik/burn-after-reading/IMAGE_NAME:VERSION

However, on step 2. I get the following error, as docker does not allow uppercases in the repository name.

$ docker tag 8f2e474ffff2 docker.pkg.github.com/Tethik/burn-after-reading/burn-after-reading:1.4.0
Error parsing reference: "docker.pkg.github.com/Tethik/burn-after-reading/burn-after-reading:1.4.0" is not a valid repository/tag: invalid reference format: repository name must be lowercase

Changing to lowercase allows me to tag the image, however doing the third step to push the image now gets an unauthorized error:

$ docker push docker.pkg.github.com/tethik/burn-after-reading/burn-after-reading:1.4.0
The push refers to repository [docker.pkg.github.com/tethik/burn-after-reading/burn-after-reading]
76f3e63d678f: Preparing
9033a17f80b4: Preparing
987962e38858: Preparing
6afa0319e02d: Preparing
4e7a8815af75: Preparing
4386e5c0a049: Waiting
1b655c784a8d: Waiting
d168ac8a1095: Waiting
4c13c63751a1: Waiting
e09c150c6aa8: Waiting
5c1068d126aa: Waiting
44ff51fbafa7: Waiting
c706028b53c1: Waiting
a67398d274c8: Waiting
3b520191885f: Waiting
08092d60523f: Waiting
d9499c02e387: Waiting
d47b056b8c3a: Waiting
3aecb0863872: Waiting
72e1f0f78475: Waiting
56a89222b908: Waiting
a89464ad2a8f: Waiting
76dfa41f0a1d: Waiting
c240c542ed55: Waiting
badfbcebf7f8: Waiting
unauthorized: Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.

Solution

So I was about to give up and file a bug report, but I managed to find a workaround.

First go to the personal access token page. Here you’ll want to create a new token with the following scopes: repo:*, write:packages, read:packages, delete:packages.

the scopes

This new token you’ll use to authenticate in the login command.

Then run the commands with lowercase instead, remembering to use the new token for the first login command as the password. So for me, an adjusted version of instructions would look as follows.

# Step 1: Authenticate
$ docker login docker.pkg.github.com --username tethik

# Step 2: Tag
$ docker tag IMAGE_ID docker.pkg.github.com/tethik/burn-after-reading/IMAGE_NAME:VERSION

# Step 3: Publish
$ docker push docker.pkg.github.com/tethik/burn-after-reading/IMAGE_NAME:VERSION

I hope this helps someone else who might have the same problem.