Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing to "library/xxx" fails #47

Closed
tianon opened this issue Sep 11, 2017 · 2 comments
Closed

Pushing to "library/xxx" fails #47

tianon opened this issue Sep 11, 2017 · 2 comments

Comments

@tianon
Copy link
Contributor

tianon commented Sep 11, 2017

Pushing to library/xxx ends up creating URLs referencing only xxx, which then fails.

The issue appears to be in the current copy of the upstream github.com/docker/distribution / github.com/docker/docker code, but it's not clear whether updating those would solve the problem (and the update is non-trivial to perform).

A full log of a failed push can be found at: https://gist.github.com/anonymous/20846e9e9aa995ddf2a6cfe72e1a4a42

(Note bits like DEBU[0018] Manifest list push url: https://registry-1.docker.io/v2/irssi/manifests/latest, which should be https://registry-1.docker.io/v2/library/irssi/manifests/latest instead, etc.)

The associated YAML file:

---
image: library/irssi:latest
manifests:
  - image: amd64/irssi:latest
    platform:
      os: linux
      architecture: amd64
  - image: arm32v5/irssi:latest
    platform:
      os: linux
      architecture: arm
      variant: v5
  - image: arm32v7/irssi:latest
    platform:
      os: linux
      architecture: arm
      variant: v7
  - image: arm64v8/irssi:latest
    platform:
      os: linux
      architecture: arm64
      variant: v8
  - image: i386/irssi:latest
    platform:
      os: linux
      architecture: 386
  - image: ppc64le/irssi:latest
    platform:
      os: linux
      architecture: ppc64le
  - image: s390x/irssi:latest
    platform:
      os: linux
      architecture: s390x

We've managed to verify our assumptions with the following patch which simply forces the upstream code to use library/xxx for official images (which we're likely going to apply locally for continuing our builds while a proper fix to this problem is found), but this isn't a great long-term solution since it modifies code in vendor/ (and we cannot see a simple solution to this which doesn't do so):

diff --git a/vendor/github.com/docker/distribution/reference/reference.go b/vendor/github.com/docker/distribution/reference/reference.go
index 52da523..3cf3d98 100644
--- a/vendor/github.com/docker/distribution/reference/reference.go
+++ b/vendor/github.com/docker/distribution/reference/reference.go
@@ -100,6 +100,13 @@ func (f *Field) UnmarshalText(p []byte) error {
 	return nil
 }
 
+func remoteName(name string) string {
+	if !strings.ContainsRune(name, '/') {
+		return "library/" + name
+	}
+	return name
+}
+
 // Named is an object with a full name
 type Named interface {
 	Reference
@@ -304,7 +311,7 @@ func (r reference) String() string {
 }
 
 func (r reference) Name() string {
-	return r.name
+	return remoteName(r.name)
 }
 
 func (r reference) Tag() string {
@@ -322,7 +329,7 @@ func (r repository) String() string {
 }
 
 func (r repository) Name() string {
-	return string(r)
+	return remoteName(string(r))
 }
 
 type digestReference digest.Digest
@@ -345,7 +352,7 @@ func (t taggedReference) String() string {
 }
 
 func (t taggedReference) Name() string {
-	return t.name
+	return remoteName(t.name)
 }
 
 func (t taggedReference) Tag() string {
@@ -362,7 +369,7 @@ func (c canonicalReference) String() string {
 }
 
 func (c canonicalReference) Name() string {
-	return c.name
+	return remoteName(c.name)
 }
 
 func (c canonicalReference) Digest() digest.Digest {
@estesp
Copy link
Owner

estesp commented Sep 12, 2017

ping @stevvooe or @dmcgowan: when you get a chance, could you let me know how push to library/ is handled in the docker client/engine? I assume there is some potential magic there which handles retaining the "library/" prefix when necessary on push..

@stevvooe
Copy link

stevvooe commented Oct 6, 2017

@estesp Sorry, completely missed this. Looks like you found a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants