Home > Software design >  Combine executables from separate Docker images?
Combine executables from separate Docker images?

Time:06-27

Let's say I need A.exe and B.exe installed in my final node image by runtime. Both A.exe and B.exe happen to be available on Docker Hub, but they're from separate images. Does Docker have a way to somehow make both executables from different images available in my final image?

I don't think Docker's multi-stage build is relevant as it only simplifies passing artefacts that we want available on the next image. Whereas in my case, I need the whole runtime environment from previous images to be available. I have the option to RUN shell commands to manually install these dependencies but is this really the only way?

CodePudding user response:

You could use a multistage build, since you could declare a.exe/b.exe together with the required runtime to be the required artefacts.

But I agree it could be easier if you install the runtime from packages and just copy the application.

CodePudding user response:

If you feel sure enough about what you need, you could export image A and image B as tar balls.

Now comes the tricky part: merging the two filesystem structures Extract both archives such that you have one target filesystem structure and wrap that up into a tar ball again.

So it is not impossible to get the files - but you need to know exactly what you are doing.

Finally import that tar ball into a docker image.

CodePudding user response:

One option to get a combined image is not to merge two images but maybe merge two dockerfiles. This may need a review once in a while but might even change less often than the images themselves.

  • Related