skip to Main Content

I would like to make a simple image that needs to be derived from a base image, then add a few files to it, some environment variables, and modify the entrypoint. Using a Dockerfile to do this is not ideal because running the Docker daemon inside our already-Docker pipeline means it needs to support Docker-in-Docker, which would make things more complex.

If images can just be represented as tar archives with a bunch of layers, it seems like there should be some tool that allows me to add a set of files as a new layer to an existing archive. I can’t find any such tool though. It seems like I could accomplish this with the Docker CLI without involving the daemon by using the following process:

  1. docker pull the base image
  2. docker save base image to a tar archive
  3. manually add the new layer to the archive
  4. docker load the archive

Manually adding a new layer in step 3 doesn’t look very straightforward though, and I’m not finding a lot of examples on how to do so (which makes me think this might be discouraged in some way).

I’m not sure if I’m searching for the wrong things, but this seems like it should be a very common use case to me. I shouldn’t need a daemon to just add a new layer with a few files… right?

2

Answers


  1. Chosen as BEST ANSWER

    Additional research sparked by the helpful links posted here led me to an npm module that seems to make it easy to make it easy to do exactly what I want: https://github.com/google/nodejs-container-image-builder

    This looks like it will make it easy to write a small node application to handle all of the heavy lifting.


  2. Docker donated the format to the OCI, which in turn published the specification. The layer specification is probably where you want to start, followed by the manifest specification.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search