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

Support tagging an image while loading image with docker load -i #40188

Open
sandipchitale opened this issue Nov 7, 2019 · 13 comments
Open

Support tagging an image while loading image with docker load -i #40188

sandipchitale opened this issue Nov 7, 2019 · 13 comments

Comments

@sandipchitale
Copy link

@sandipchitale sandipchitale commented Nov 7, 2019

Description

Depending on how docker image tar was saved it does not have tags recorded in it. So I use

docker load -i image.tar

I get an image with out a tag.

Steps to reproduce the issue:

  1. Use
docker load -i image.tar

command to load a image tar which does not have tag
2. run

docker images

and see that the docker image does not have a tag.

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:26:49 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:32:21 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
@yedamao
Copy link
Contributor

@yedamao yedamao commented Nov 8, 2019

Client: Docker Engine - Community
 Version:           19.03.4
 API version:       1.40
 Go version:        go1.12.10
 Git commit:        9013bf5
 Built:             Thu Oct 17 23:44:48 2019
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.4
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.10
  Git commit:       9013bf5
  Built:            Thu Oct 17 23:50:38 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

save and load image with tags correctly

@928234269
Copy link

@928234269 928234269 commented Nov 21, 2019

you can try "docker save demo/demo:1.0 -o demo.tgz" .then "docker load -i demo.tgz"
Use the image tag to save the image and get the tag when loading.

@sandipchitale
Copy link
Author

@sandipchitale sandipchitale commented Nov 21, 2019

I think this works if the tag was used at the time of saving, I can get the tag back. I am talking about the case whereby the tag was not used to save the image, but SHA was. In this case it will be great to have a way to tag the image while loading. That is what this feature request is about.

@salimsaid
Copy link

@salimsaid salimsaid commented Feb 23, 2020

#dibs

@salimsaid
Copy link

@salimsaid salimsaid commented Feb 27, 2020

@sandipchitale Can you please re-assign this task to me ?
I would like to work on it.

@ilya-korotya
Copy link

@ilya-korotya ilya-korotya commented May 3, 2020

Hi @sandipchitale @AkihiroSuda. For clarity. Do you want a workflow like this?

  1. I build a container with a tag:
docker build -t myapp:v1 .
  1. Then I get images like this:
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
myapp               v1                  76cfa8011d00        About a minute ago   803MB
  1. I save the image with IMAGE ID
docker save 76cfa8011d00 -o myapp.v1.tgz
  1. Load the image:
docker load -i myapp.v1.tgz

Current behavior after executed commands:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              76cfa8011d00        2 minutes ago       803MB

Expected behavior after commands executed:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
myapp             v1              76cfa8011d00        2 minutes ago       803MB
@AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented May 3, 2020

The name:tag should be specified explicitly like docker load -t myapp:v1 -i myapp.v1.tgz

@ilya-korotya
Copy link

@ilya-korotya ilya-korotya commented May 4, 2020

I think if we will use -t flag with *.tgz file which contains two or more images (because save command can save more then one image to archive) we will get an error because we can't set one tag for different images.
Hmmm. But here we don't check error
@AkihiroSuda How should we do when one *.tgz file contains many images?

@AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented May 4, 2020

Maybe we should give up supporting this proposal then, and instead we should support docker load --format "{{json .}}" -i myapp.v1.tgz | some-external-script so that external shell script can handle untagged images

@ilya-korotya
Copy link

@ilya-korotya ilya-korotya commented May 4, 2020

Maybe we should give up supporting this proposal then, and instead we should support docker load --format "{{json .}}" -i myapp.v1.tgz | some-external-script so that external shell script can handle untagged images

I think it's a good idea. But we can add -t flag only for one image in *.tgz and return an error or a warning when *.tgz contain more images.

@ilya-korotya
Copy link

@ilya-korotya ilya-korotya commented May 5, 2020

@AkihiroSuda I found a better way. In the current workflow we have an image:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
customtag           v1                  bf756fb1ae65        4 months ago        13.3kB

If we save this image via a tag:

docker save customtag:v1 -o customtag.v1.tgz

And after we load this image from customtag.v1.tgz file. We got the image with the tag:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
customtag           v1                  bf756fb1ae65        4 months ago        13.3kB

I think need to save tags also when we save image via id(docker save bf756fb1ae65...) and restore tags when we make load command. And after this work user can run an external script for change default tags:

docker image list --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}" | external-script
@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented May 5, 2020

Multiple tags can refer to an ID though, so I'm not sure we should include all tags that reference that ID

@ilya-korotya
Copy link

@ilya-korotya ilya-korotya commented May 5, 2020

Hmmm. I think we should include all the tags for one ID.
For example, I have an image with different tags and common IMAGE_ID. I saved my image via id:

docker save IMAGE_ID -o app.tgz

And when I load image from app.tgz I want to have same tags as before. Like:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
custom              v1                  bf756fb1ae65        4 months ago        13.3kB
hello-world         latest              bf756fb1ae65        4 months ago        13.3kB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.