Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy Docker images from one host to another without using a repository

Tags:

docker

How do I transfer a Docker image from one machine to another one without using a repository, no matter private or public?

I create my own image in VirtualBox, and when it is finished I try to deploy to other machines to have real usage.

Since it is based on my own based image (like Red Hat Linux), it cannot be recreated from a Dockerfile. My dockerfile isn't easily portable.

Are there simple commands I can use? Or another solution?

like image 548
Larry Cai Avatar asked May 29 '14 13:05

Larry Cai


People also ask

How do I copy a docker image without repository?

In order to transfer a Docker image from one server to another, what you need to do is first export the image to a file, then copy that file over from your current server to the new one using scp or rsync and finally load the image to your new server.

Can we copy docker images from one host to another?

You can also use the DOCKER_HOST variable to copy images from one host to another. You will need the SSH credentials and both the users on the local and remote machines should be in the Docker group.

What is the method of directly transferring a docker image from one host to another?

2. Container image migration. The most commonly used method to move Docker container to another host, is by migrating the image linked to that container. For the container that has to be moved, first its Docker image is saved into a compressed file using 'docker commit' command.


1 Answers

You will need to save the Docker image as a tar file:

docker save -o <path for generated tar file> <image name> 

Then copy your image to a new system with regular file transfer tools such as cp, scp or rsync(preferred for big files). After that you will have to load the image into Docker:

docker load -i <path to image tar file> 

PS: You may need to sudo all commands.

EDIT: You should add filename (not just directory) with -o, for example:

docker save -o c:/myfile.tar centos:16 
like image 131
Daiwei Avatar answered Sep 28 '22 06:09

Daiwei