Error when trying to push docker image to package registry

This isn’t an issue with actions but with trying to push an image to the github docker registry for the first time. I’ve read the docs and logged in and tagged the image. But when pushing the image, I get this error:


docker push docker.pkg.github.com/timboring/$repo/$image-name:1.0  
The push refers to repository [docker.pkg.github.com/timboring/$repo/$image-name]  
a2685daee41f: Preparing  
7d995aecbba4: Preparing  
b3d0f3e3ea19: Preparing  
cae263f71af5: Preparing  
3bea0ae9601f: Preparing  
8e4416244b07: Waiting  
6189957aede5: Waiting  
c3299dda2945: Waiting  
5191bfc553a0: Waiting  
0db5724f9017: Waiting  
7f61afcc4a4d: Waiting  
8cec11e3dff0: Waiting  
f1b5933fe4b5: Waiting  
name unknown: The expected resource was not found.

1 Like

Hi @timboring ,

Please check with command ‘docker images’, make sure the image info is correctly transferred to the docker push command. Please note that foreign layers (eg: windows images) are not supported.

My successful docker push workflow for your reference: https://github.com/weide-zhou/dockerWebApi/runs/591517216?check_suite_focus=true

If it persists, could you please share your repo/sample repo for further investigation?

I’m getting this too. Here is a simple test that fails for me:

% cat ~/GH_TOKEN.txt | docker login docker.pkg.github.com -u shaunc --password-stdin
Login Succeeded
% docker pull alpine:3.11
3.11: Pulling from library/alpine
Digest: sha256:b276d875eeed9c7d3f1cfa7edb06b22ed22b14219a7d67c52c56612330348239
Status: Image is up to date for alpine:3.11
docker.io/library/alpine:3.11
% docker tag alpine:3.11 docker.pkg.github.com/factfiber/test/alpine:3.11
% docker push docker.pkg.github.com/factfiber/test/alpine:3.11
The push refers to repository [docker.pkg.github.com/factfiber/test/alpine]
beee9f30bc1f: Preparing 
name unknown: The expected resource was not found.

… in case this is useful:

% docker version
Client: Docker Engine - Community
 Version: 19.03.8
 API version: 1.40
 Go version: go1.12.17
 Git commit: afacb8b
 Built: Wed Mar 11 01:21:11 2020
 OS/Arch: darwin/amd64
 Experimental: false

Server: Docker Engine - Community
 Engine:
  Version: 19.03.8
  API version: 1.40 (minimum version 1.12)
  Go version: go1.12.17
  Git commit: afacb8b
  Built: Wed Mar 11 01:29:16 2020
  OS/Arch: linux/amd64
  Experimental: false
 containerd:
  Version: v1.2.13
  GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version: 1.0.0-rc10
  GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version: 0.18.0
  GitCommit: fec3683
 Kubernetes:
  Version: v1.15.11-eks-af3caf
  StackAPI: Unknown

I’m getting this too. Here is a simple test that fails for me:

$ cat ~/GH_TOKEN.txt | docker login docker.pkg.github.com -u shaunc --password-stdin
Login Succeeded
$ docker pull alpine:3.11
3.11: Pulling from library/alpine
Digest: sha256:b276d875eeed9c7d3f1cfa7edb06b22ed22b14219a7d67c52c56612330348239
Status: Image is up to date for alpine:3.11
docker.io/library/alpine:3.11
$ docker tag alpine:3.11 docker.pkg.github.com/factfiber/test/alpine:3.11
$ docker push docker.pkg.github.com/factfiber/test/alpine:3.11
The push refers to repository [docker.pkg.github.com/factfiber/test/alpine]
beee9f30bc1f: Preparing 
name unknown: The expected resource was not found.

In case it is helpful:

% docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
 Kubernetes:
  Version:          v1.15.11-eks-af3caf
  StackAPI:         Unknown

Hi @shaunc ,

I can successfully push docker image to package registry with your code, my workflow here.

Are you using macOS selfhosted runner? Currently docker is only supported for linuxOS on github, and foreign docker layers are not supported. Please try to use ubuntu hosted runner for a try. Thanks.

Ah … I am using macOS. Hmm… perhaps I’ll have to try kaniko – it should work with kaniko, right?

What do you mean by “foreign”? Can I use alpine, or distroless? I thought a layer was pretty much a binary with a bunch of metadata.

Hi @shaunc ,

Sorry I’m not familiar with kaniko, you can have a try. 

When you use macOS self hosted runner to pull, tag…the docker image, it could add/change docker layer as a foreign one. Hence, based on my success workflow with your code, it’s recommended to use github hosted runner instead.

Hi @timboring , could you please confirm whether it’s same with you and if it works for you with github hosted runner?

Thanks.

Hello,

Any progress on this problem?

I got the same problem,

root@jumpbox:~# docker push docker.pkg.github.com/orgnization/repo/alpine:3.11

The push refers to repository [docker.pkg.github.com/orgnization/repo/alpine]

3e207b409db3: Preparing

name unknown: The expected resource was not found.

And I’m using Ubuntu as jumpbox to push the docker image.

Can you please help?

Same problem here.

In the end it is all in the naming of the fully qualified name of the docker image

The fully qualified name of the docker image must follow the following format

docker.pkg.github.com/OWNER/REPOSITORY/IMAGE\_NAME:VERSION

Where

  1. docker.pkg.github.com” is the domain name for the github docker packages service

  2. “OWNER” is the name of the account

  3. “REPOSITORY” is the name of the git repository containing your source code

  4. “IMAGE_NAME” is the name you have chosen for your image

  5. “VERSION” is the version you have chosen for your image.

If you do not provide the exact names of your account and github git repository docker will provide you with the obscure error message “name unknown: The expected resource was not found.”

Only IMAGE_NAME and VERSION can contain names and values of your choice.

In my case fixing the REPOSITORY part to match my github source code repository solved the problem. 

The more convenient name I used was not acceptable :frowning:

Ah … grumble … was using company name as repository. Hmm… this makes this registry much less flexible – I wanted to push all sorts of images here, not necessarily tied to particular code repositories. :confused: … but thanks @jmdales !

Actually it makes kind of sense - at least to me - for Github Packages to be tightly connected to repositories. (Personally I would like for versions of the packages to be more connected to the branches of git repositories.)

What is kind of bad with naming - you can have only one <IMAGE_NAME> in <OWNER> account completely missing the <REPOSITORY> slug. So you cannot have <OWNER>/repo1/<IMAGE_NAME> and <OWNER>/repo2/<IMAGE_NAME> in one user account. But you have to have <OWNER>/repo1/image1 and <OWNER>/repo2/image2. I consider this a bug.

Thanks @jmdales @shaunc for pointing out the repository name issue.

Hi @timboring , could you please check if it works for you? Thanks.

Had the same issue. Turned out it came from the insufficient scopes allowed for my token. I only gave the packages relative ones, but you also need the repo ones.

2 Likes