Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker save/load lose original image repository/name/tag

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?

like image 894
Zizou Avatar asked May 13 '17 19:05

Zizou


People also ask

Does docker tag creates a new image?

Docker tags make it easy to benefit from the hard work of others by running their images directly or by creating new derived ones. Simply head over to Docker Hub, choose a tag, and each time you pull the image, you'll get the latest version pushed by the authors.

What is the default tag for a docker image?

3.3. Here, in the above command, we built the image without any tag, so By default, Docker provides a tag to the image as the latest “baeldung-java:latest”. Docker always points to the latest stable release using the latest tag.


2 Answers

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 
like image 161
csu007 Avatar answered Sep 21 '22 20:09

csu007


I had the same problem, so I used the following command to fix it manually:

docker tag <Image-ID> <desired Name:Tag>

Reference


[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.

Reference

like image 22
Benyamin Jafari Avatar answered Sep 18 '22 20:09

Benyamin Jafari