I am trying to push images I have built locally to the GitHub Container Registry aka Packages. I have authenticated GitHub using PAT and authorized access to the organization. Let's name this organization EXAMPLEORG. used the following command:
export CR_PAT=ghp_example_pat ; echo $CR_PAT | sudo docker login ghcr.io -u exampleuser --password-stdin
After that, I used the following command to push the image to ghcr.io:
docker push ghcr.io/exampleorg/exampleapp:v0.5
Unfortunately, I am getting this message after trying to upload image layers:
unauthorized: unauthenticated: User cannot be authenticated with the token provided.
Does somebody knows what I am missing here?
Followed this guide: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry
Is there something more I need to do in order to manually push image to Org packages (not interested to do it from the workflow at the moment).
Apparently, it was due to the wrong content of the ~/.docker/config.json
file. During the first command, it happens to fail while writing. So I used sudo
to circumvent this, and indeed it was circumvented, but the new file is now written in /root/.docker/config.json
which is not desired outcome. Using docker login
afterward will not read the config file from the root's home.
The solution to this is not to use sudo
instead delete ~/.docker/config.json
and then execute:
export CR_PAT=ghp_example_pat ; echo $CR_PAT | docker login ghcr.io -u exampleuser --password-stdin