Build docker image from layers

I have a big docker image I need to copy to a remote machine. I build the image on my local machine with an unchanging base image, so only the last few layers change. I would like to have that base image on the remote machine and only copy the changed top layers to the remote machine whenever they change. I cannot build the image on the remote using its dockerfile because the necessary source files are not present on the remote.

I can separate the image into its layers using undocker, but how do I reassemble the image from its layers on the remote machine?

1 answer

  • answered 2018-11-08 07:31 Mark Bramnik

    I've never worked with undocker tool so I can't comment on this, but in my understanding image in docker is a "sealed package" ready for distribution in one way or another.

    So copying part of the image sounds to me like distributing a part of the package.

    I can understand that overhead of big image on the other hand (probably you're looking for faster copying), but it contradicts the docker "ideology" (take image "as is" and work with it)

    So, probably the most straightforward option is preparing the sources (those are in the "last few layers") as a distributable package without docker, copying them to the remote machine and then building the image on the remote machine out of a base image and this distributable package

    This allows overcoming a workaround of "the necessary source files are not present on the remote" as you say