Reputation: 2299
What would be the best practice when I need to create multiple docker images that share the same instructions EXCEPT the FROM image?
For example, I want to build 3 different images - a Java stack, a Python stack, and a Rust stack. So I have 3 Dockerfile's each referencing a different FROM image. Then, in each of these Dockerfile, I have a long list of instructions that are exactly the same. I would rather not duplicate the instructions.
Upvotes: 0
Views: 114
Reputation: 4059
You can try passing image name as arguments if only image name is changing
Dockerfile:
ARG img
FROM $img
RUN echo “Building $img”
Then run build command on terminal:
sudo docker build . --build-arg img=busybox
Upvotes: 2