Moving a large docker image without the repository & How to split and merge files in Linux

Problem


After getting Apex running with Docker, I had to import data into it, then move the docker image to another machine. Apprantly this is what Docker is great at: Just push the image to the respository then pull it from the other machine. Right? Wrong! I had a 16gb image, and try as I might I could not get it to got passed 50mb, with constant false starts and jams along the way. So I decided to try another way: why not export the docker image as a file, move it to the other machine (FTP or via the cloud), the import the machine on the other side?

Solution


You will need to save the docker image as a tar file:
docker save -o <save image to path> <image name>
Then copy your image to a new system with regular file transfer tools such as cp or scp. 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

Splitting the files up in Unix and putting them back together again.

In my case I ended up with a very large file on my hands. So I decided to split it up for easy transfer.

Lets says I have an image and its too big (10MB). All I do is:
split --bytes=1M /path/to/image/image.jpg /path/to/image/prefixForNewImagePieces
and then to put it together I use cat:
cat prefixFiles* > newimage.jpg

Acknowledgements

http://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-via-repository
http://askubuntu.com/questions/54579/how-to-split-larger-files-into-smaller-parts




Comments