قالب وردپرس درنا توس
Home / Tips and Tricks / How to package and transfer docker images from one server to another – CloudSavvy IT

How to package and transfer docker images from one server to another – CloudSavvy IT



If you have built a Docker image on your development machine and want to distribute it on a server, you can use a Docker registry, but Docker also has tools for saving images to files and uploading them to another server.

You do not need a container register

Typically, you use a Docker container registry to transfer a building of a container (called an image) to a remote server. This is the best method ̵

1; it is a single authority, which makes it easy to distribute updates across multiple servers. It also does not require you to make the container public. There are many good private container records, such as Google’s GCR and AWS ECS. Docker Hub also supports private repositories. If you are only concerned about privacy, switch to a private registry and continue to use docker push and docker pull.

But for those who want to do it the old-fashioned way, Docker CLI includes some tools for saving images in files and uploading them to a remote server.

To save an image, you can use docker save, specify an output file, and then enter an image name and tag:

docker save -o ./savedimage imagename:tag

If you do not specify a tag, Docker packages all tags.

This serials and saves a copy of the image below the output file. The image is stored as a tar file. If you want to save it as one tar.gzyou can omit -o flag and touch the exit to gzip:

docker save imagename:tag | gzip > savedimage.tar.gz

You can then take this file and scp or FTP copy to the destination server. Once there, you can use it docker load to import it again:

docker load -i savedimage

This makes the image available in the target system as if you had run docker build . -t imagename. You can use it just like a locally built image with docker container run:

docker container run imagename

Source link