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

Saved Image Missing RepoTags #201

Closed
cholick opened this issue May 30, 2018 · 3 comments
Closed

Saved Image Missing RepoTags #201

cholick opened this issue May 30, 2018 · 3 comments

Comments

@cholick
Copy link

cholick commented May 30, 2018

This seems a bit related to #78, but isn't the same issue.

When I do a docker save, the manifest.json in the tar file includes a populated RepoTags array. For example, after running

 docker save gcr.io/kubernetes-helm/tiller:v2.8.2 -o tiller.2.8.2.tgz

the tarball has:

...
  "RepoTags": ["gcr.io/kubernetes-helm/tiller:v2.8.2"],
...

In contrast, the /image file in concourse has an empty RepoTags:

...
  "RepoTags":null
...

/tag is correctly populated: unlike #78, and I am specifying a concrete version.

The docker load command uses that manifest's metadata, such that using the image saved via docker's cli:

docker load -i tiller-v2.8.2.tgz

results in an image with proper repository and tag:

$ docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
gcr.io/kubernetes-helm/tiller        v2.8.2              1c5314e713c2        2 months ago        71.6MB

but loading an image generated via concourse does not.

Example pipeline used to test:

---

resources:
- name: tiller-image
  type: docker-image
  source:
    repository: gcr.io/kubernetes-helm/tiller
    tag: "v2.8.2"

jobs:
- name: image-test
  plan:
  - aggregate:
    - get: tiller-image
      params:
        save: true
  - task: do-test
    config:
      inputs:
      - name: tiller-image
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: bash
      run:
        path: bash
        args:
        - -exc
        - |
          echo "Exit 1 to keep around container"
          exit 1
@cholick
Copy link
Author

cholick commented May 30, 2018

Hesitate to claim this ugly hack, but... if anyone gets to this issue via Google search, probably using this as a stopgap workaround:

---
resource_types:
- name: gcs-resource
  type: docker-image
  source:
    repository: frodenas/gcs-resource

resources:
- name: tiller-image
  type: docker-image
  source:
    repository: gcr.io/kubernetes-helm/tiller
    tag: "v2.8.2"

- name: output-test
  type: gcs-resource
  source:
    bucket: temp-delete
    regexp: image.tar
    json_key: {....}

jobs:
- name: image-test
  plan:
  - aggregate:
    - get: tiller-image
      params:
        save: true
  - task: do-test
    config:
      inputs:
      - name: tiller-image
      outputs:
      - name: out
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: <some image with python and bash>
      run:
        path: bash
        args:
        - -exc
        - |
          pushd tiller-image
          mkdir -p new-image out
          pushd new-image
          tar -xvf ../image
          popd

          cp new-image/manifest.json manifest.json.bk

          echo '
          import json

          with open("repository") as repo_file:
          	repo = repo_file.read().strip()

          with open("tag") as tag_file:
          	tag = tag_file.read().strip()

          with open("new-image/manifest.json", "r+") as file:
          	manifest = json.load(file)
          	repo_tags = ["{}:{}".format(repo, tag)]
          	manifest[0]["RepoTags"] = repo_tags
          	new_manifest = json.dumps(manifest)

          	file.seek(0)
          	print("\n", new_manifest, "\n")
          	file.write(new_manifest)
          ' > fix_manifest.py

          python fix_manifest.py

          tar -cvf ../out/new-image.tar -C new-image $(ls new-image)

  - put: output-test
    params:
      file: out/new-image.tar

@tchaloupka
Copy link

I've been bitten by this too.
It's because of:

image_name="${repository}@${digest}"

And the behavior described here: moby/moby#3877

Thx for the workaround.

@xtremerui
Copy link
Contributor

Unfortunately we have to use image_name="${repository}@${digest}" since later the variable is used for docker pull (as mentioned in moby/moby#3877 digest to image could be 1:M mapping) and digest is unique.

Giving that moby/moby#3877 is closed and solution is available if one wants to have the repo & tag saved in output image, i will closing this issue now.

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