Is it possible to merge two base images in Docker? #4855
-
DescriptionI did not know where to post this feature request related to the I'm stuck at this problem. I have a custom image for my API that inherits from However, I need node.js in my API projects, and I also need some stuff that I install in my custom API image, in my react and site images. I need to be able to create a common base image that combines both Can you please add that functionality? Is that possible? Is it an easy task? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello! There might be some confusion here concerning Docker layers and execution. In such a case, I suggest selecting a single base image and then adding any missing functionality to that base. As a path forward, it might be best to become familiar with multi-stage builds and then leverage the dockerfile best practices to craft a Dockerfile that can achieve the end product you're looking for. Alternatively, based on the tech stack mentioned, it might be helpful to evaluate using docker compose to run multiple containers as a single stack. You can even use compose with devcontainers. |
Beta Was this translation helpful? Give feedback.
-
To merge layers from both images together you can do
If that resulting image works is another question. Probably not as |
Beta Was this translation helpful? Give feedback.
To merge layers from both images together you can do
If that resulting image works is another question. Probably not as
node:lts-bookworm-slim
is already a full image, not just the node package that you probably want on top of you base image instead.