I'm using Docker 1.12.6.
I have pulled an image from the Docker registry. I have exported the images as tar files using the docker save
command.
I removed the original image and container and loaded the exported image using docker load -i myImage.tar
.
Now, when running docker images
I notice my image have lost its repository/tag information:
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 5fae4d4b9e02 8 weeks ago 581.3 MB
Why does it have this behavior and how do I keep the original image name?
Use
docker save -o filename.tar <repo>:<tag>
The command docker save <image id>
removes the repository and tag names.
To solve this, use docker save <repo>:<tag>
it will keep the repository and tag name in the saved file. For example:
docker save -o ubutu-18.04.tar ubuntu:18.04
I had the same problem, so then I used with the following command to fix it manually:
docker tag <Image-ID> <desired Name:Tag>
[ NOTE ]:
It's inconsistent:
docker save image-repo-name
->docker load
restores name,docker save SHA
->docker load
no names or tags,docker save name:latest
->docker load
no names or tags.
AND :
The current (and correct) behavior is as follows:
docker save repo
Saves all tagged images + parents in the repo, and creates a repositories file listing the tags
docker save repo:tag
Saves tagged image + parents in repo, and creates a repositories file listing the tag
docker save imageid
Saves image + parents, does not create repositories file. The save relates to the image only, and tags are left out by design and left as an exercise for the user to populate based on their own naming convention.
A single image ID can have multiple names/tags, so the way that you loose the the names and tags is what I would expect to happen after saving and loading the image to/from a tar ball.
Mode details are in the discussion about it here
From docker documentation:
cat exampleimage.tgz | docker import - exampleimagelocal:new
root@mymachine:/tmp# cat myimage.tar | docker import --message "New image imported from tarball" - reponame:my-image-name
sha256:be0794427222dcb81182a59c4664b350ecb5ffb7b37928d52d72b31
root@mymachine:/tmp# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
reponame my-image-name be0794427222 6 seconds ago 4.31GB
This one worked for me.
This is a work around
Go to source docker host machine, create text file containing all the image details using the following command docker image ls > images.txt
The above command will produce a text file similar to the following REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> 293e4ed402ba 2 weeks ago 315MB <none> <none> d8e4b0afd6ba 2 weeks ago 551MB
Make necessary edits to set the tag by using docker image tag
command
docker image tag 293e4ed402ba postgres:latest docker image tag d8e4b0afd6ba wordpress:latest
I wrote a one-line script that importing a bunch of .tar files and immediately tagging the image.
for image in $(ls); do docker tag "$(echo $(docker import $image))" $image ; done
Note, that you should be inside the folder when all the tar files are located.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.