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
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.
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.
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.
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 ...
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With