0

I know about /var/lib/docker but is mounting this directory on another machine enough to recover the docker functionality on the original machine? I tried this between different CoreOS instances but when issued docker image the images did not appear even though they were in the /var/lib/docker directory. Am I missing some other data that should be transferred?

The end goal is to have a portable 'repo' of images that I can build on from any machine.

related Where are Docker images stored on the host machine?

Community
  • 1
  • 1
Majid alDosari
  • 133
  • 1
  • 2
  • 13
  • 1
    If there isn't anything secret in your docker images, you can upload them to the public docker hub. But then other people can use them too. You can also set up a private docker hub. When you `docker run` something that isn't there, it goes to the public hub to find it. – Paul May 11 '15 at 23:05
  • i know but i need to do this specifically so i can `docker build` w/o having to start from scratch. if i docker build then push to the repo, delete local img, pull img again from repo, the intermediate build layers are gone. Because when I docker build again I see that it's not pulling from the (local) cache. – Majid alDosari May 11 '15 at 23:16
  • i see the use of a registry as nice for a 'finished' product. – Majid alDosari May 11 '15 at 23:26
  • You want to pull before you build, then you will have the intermediary layers in cache. – Michael May 12 '15 at 02:30
  • @Michael i did that and it doesn't work...the way i'd like. after some investigation, it turns out that when i build my image locally, then *tag* it into my private repo server, the tagging changes the image ids. this is not what i'd like but i guess i can live with it. i don't like it bc i only want to think in images w/o association with the server name which can change. – Majid alDosari May 13 '15 at 16:12
  • 1
    Tagging should not change image ids - only building should change the image id. – Michael May 13 '15 at 16:22
  • @Michael i've confirmed that tagging doesn't change image ids but i still haven't figured out my problem. but something that i don't get is that different image ids are generated for the same dockerfile on different instances/hosts. so if i push those into my registry it might mess things up. though i'm still investigating. – Majid alDosari May 16 '15 at 20:13
  • Building a new image will create a new image id unless the previous image is already there and nothing has changed. – Michael May 17 '15 at 20:36

4 Answers4

1

docker export, scp from machine A to machine B, and docker import should work well for you.

Rob
  • 2,426
  • 17
  • 11
0

I think in order for you to transfer docker images like this they have first be compressed as tar's.

0

for the above query,if i am not wrong, you want to transfer images(all images) to a remote machine.

An easy way for this approach is creating a registry on the second machine(say machine B) and push all images from the main machine(machine A).

However i suspect that there is some permission problem with the local mount point which you are referring.I suggest you to first check out with chmod 777 command on the localmount point.Then if it works you can give access with restricted permissions.

Similarly, I have not tried mounting on other machine /var/lib/docker but incase if it had to work you should give permission and it should be owned by docker group.

Let us know if it is the permission issue that you faced. good luck

Pratik
  • 1,216
  • 11
  • 18
0

So in my solution I use both a private docker registry and a 'shared' /var/lib/docker that I mount between my (ephemeral) instances/build machines. I intend to use the registry to distribute images to machines that wont be building. Sharing the docker dir helps with keeping the build time down. I have the following steps for each dockerfile.

docker pull          $REGISTRY_HOST/$name
docker build                    -t  $name $itsdir
echo loading into registry \
                 $REGISTRY_HOST/$name
#assuming repos in 'root' ( library/ )
docker rmi           $REGISTRY_HOST/$name
docker tag    $name  $REGISTRY_HOST/$name
docker push          $REGISTRY_HOST/$name
docker rmi           $REGISTRY_HOST/$name

I think this works.

Majid alDosari
  • 133
  • 1
  • 2
  • 13