Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker save without docker pull

Tags:

docker

I would like to save a docker image as a tar file. I can

docker pull my_repo/image:latest
docker save -o image.tar my_repo/image:latest

Is there a way to bypass the docker pull? What I would like to do is just

docker save -o image.tar my_repo/image:latest

When I try docker save alone I get: Error response from daemon: reference does not exist

Thanks

like image 568
spbarbieri Avatar asked Jul 12 '18 15:07

spbarbieri


People also ask

How do I store docker images locally?

If you use the default storage driver overlay2, then your Docker images are stored in /var/lib/docker/overlay2 . There, you can find different files that represent read-only layers of a Docker image and a layer on top of it that contains your changes.

How do I save a running docker container?

The usual way is at least through a docker commit: that will freeze the state of your container into a new image. But know that there is no reliable way to "save state" of container unlike virtual machine save state in Hyper-V or VMware. This is a downside also to docker.

Is it possible to save an image without a Docker pull?

Thank you, this worked for me! Just a note, you will have to first pull the image using docker pull couchbase, before running the docker save command (otherwise docker save will have no reference image to find) This doesn't answer the question, which was specifically how to save an image WITHOUT doing a docker pull first.

What are the advantages of Docker pull?

Advantages of Docker Pull 1 It helps to download the images from any registry, it might be a public registry or private registry. 2 It can even pull the whole repository if required using the ‘–all-tags’ option. 3 It helps to download unsigned Docker images, however, we should aware of risks while doing so. More ...

How to pull Docker images from Docker Hub?

Scenario: – Different ways to pull Docker images from Docker Hub. 1. Pull the ‘alpine’ image without any tag as shown below: In the above example, we can see that if we don’t provide any tag, the Docker daemon pulls the image with the ‘latest’ tag by default and pull the image only if there is an image that exists with the latest tag. 2.

What is the difference between save and export in Docker?

But, save is used for images and can save multiple images into a tar file with all the layers and history. export is used for containers without any history or layers. docker import is used with tarballs which are exported and docker load is used with tarballs which are saved with save command.


1 Answers

You have to actually have the image locally before you can docker save it. (Unlike docker run it won't pull it on its own.)

If you have the source to the image, it works equally well to

docker build -t my_repo/image:latest .
docker save -o image.tar my_repo/image:latest

If you don't then you need to docker pull it first, as you have in the question; there's no way around this.

like image 121
David Maze Avatar answered Sep 27 '22 22:09

David Maze