The Dockerfile reference says the following about the FROM instruction:
FROM
can appear multiple times within a singleDockerfile
in order to create multiple images. Simply make a note of the last image ID output by the commit before each newFROM
command.
I don't understand what they mean by note the last image ID output by the commit. I'm not really sure I see the point at all in having multiple FROM
instructions.
Is there any valid use case of this?
The FROM keyword tells Docker to use a base image that matches the provided repository and tag. A base image is also called a parent image. In this example, ubuntu is the image repository.
Differences between CMD & ENTRYPOINT CMD commands are ignored by Daemon when there are parameters stated within the docker run command while ENTRYPOINT instructions are not ignored but instead are appended as command line parameters by treating those as arguments of the command.
#Note: image1 and image2 can be same
FROM image1
.. any commands for image1
FROM image2
.. any commands for image2
It will create two images. It will return latest image id after the build(as the doc says). So this usage is possible(I didn't see that usage yet.), but in my opinion it can be used on exceptional cases. It doesn't seem a nice usage to build two different images and reaching first image id.
May be your requirement is building mass applications and able to build once a time together. So it's up to your requirement. Do you really need this usage is the main question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With