When I try:
docker push ghcr.io/username/imagename:latest
as per GitHub docs, I see
unauthorised: unauthenticated: User cannot be authenticated with the token provided.
How do I push the image to ghcr?
When I try:
docker push ghcr.io/username/imagename:latest
as per GitHub docs, I see
unauthorised: unauthenticated: User cannot be authenticated with the token provided.
How do I push the image to ghcr?
You have to give docker permission to push to your GHCR (instructions are in the github docs, but are somewhat buried).
3 Steps:
Create an access token (PAT) (here) and give it read/write packages permissions.
Copy the PAT to clipboard, and run this in your terminal:
docker login ghcr.io -u username -p ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
replacing username
with your GitHub username, and ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
with the PAT you just made. Now docker has access to your GHCR, including the ability to push.
push
command again and it will work:docker push ghcr.io/username/imagename:latest
You need to grant Docker the necessary permission to push your GitHub container Registry (GHCR). The following steps worked for me.
Step 01
Generate a Personal Access Token (PAT) with permissions to read and write packages.
You can create one Here
Step 02
Copy the PAT and execute the following command in your terminal
docker login --username username --password YOUR_PAT ghcr.io
Make sure to replace username with your GitHub username and YOUR_PAT with the token you just generated. This will authenticate Docker with your GHCR for pushing images.
Step 03
Run your push command again
docker push ghcr.io/username/imagename:latest
After completing these steps, you should be able to push your image successfully!
© 2022 - 2024 — McMap. All rights reserved.