Reputation: 4997
I use docker-compose for local development on my Mac. I have multiple images being built with docker compose. My docker and docker-compose set up is very standard. Now I want to share my locally built image file with someone. Where are these local files stored?
Searching a bit gave me answers like:
~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
But then how can I extract one image from this and share? I tried running the tty
that is present with it, but to no avail.
Docker Version: 18.03 Docker for Mac
Docker compose Version: 2
Upvotes: 0
Views: 1849
Reputation: 4997
Apparently, the solution with docker-compose
is using the docker save
command. We do not need to know the locations of images as @fly2matrix mentioned. We can use the docker save
command to save the image in TAR file.
docker save --output image-name.tar image-name:tag
Then this image can be shared and loaded by other users through:
docker load --input image-name.tar
Upvotes: 2
Reputation: 2467
If you have docker-hub account (which is free), then you can use docker push command to save docker image into registry and use docker pull to pull on other machine.
Another solution is to use save + import commands.
For that you can use docker save
and docker import
commands.
docker@default:~$ docker save --help
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o, --output string Write to a file, instead of STDOUT
docker@default:~$
After that you have TAR file on your file system (check -o value) then transfer the file to another machine and execute docker import
docker@default:~$ docker import --help
Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Import the contents from a tarball to create a filesystem image
Options:
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Set commit message for imported image
docker@default:~$
Upvotes: 2