Skip to main content

How to share docker images without Docker hub or any registry

https://miro.medium.com/v2/resize:fit:700/1*4SackdckgQylqePqMm2RgA.png

There are some instances where you can’t publish your image to the docker hub or any private registry. This story gives you options on how to share your images without publishing them to the docker hub or any private registry. save and load are the two commands which we can use for this purpose

Docker Hub Images

Let’s pull the busy box from the docker hub.

mkdir saveimage
cd saveimage
docker pull busybox

https://miro.medium.com/v2/resize:fit:700/1*dwoQR0GkpQiIYj_G0eY8UQ.png

docker has a save command where you can save into a tar file. We can list the directory after saving.

docker save busybox > busybox.tar

https://miro.medium.com/v2/resize:fit:700/1*kKBMoGoyP6npc88pMYNp2w.png

Let’s list all the images and remove the busybox image from the local docker registry.

https://miro.medium.com/v2/resize:fit:700/1*AwQ0R5lqH6QqQGBrBJUjgA.png

Load the image from the tar file. once you load the image you can interact with it and run the container as an official image.

docker load < busybox.tar

https://miro.medium.com/v2/resize:fit:700/1*eGfVgRGE-tM9hKSegs8NLQ.png

Customized Images

we can do the same thing with user-customized images as well. Let’s clone this repo and see how it works.

git clonehttps://github.com/ahmedbhl/dockerfiles-cmdvsentry.git

Build the docker image with this command

docker build -t nodeversion -f echo/Dockerfile.cmd .

https://miro.medium.com/v2/resize:fit:700/1*eKxfNiHRJ5FUC-_Wch115Q.png

Use save command to save the image to the tar file.

// save to tar file
docker save nodeversion > nodeversion.tar// load from tar file
docker load < nodeversion.tar

https://miro.medium.com/v2/resize:fit:700/1*nhuW0ctPmrfWpEFFIMsK3A.png