qarthandso
qarthandso

Reputation: 2188

Dockerfile FROM Instruction

The Dockerfile reference says the following about the FROM instruction:

FROM can appear multiple times within a single Dockerfile in order to create multiple images. Simply make a note of the last image ID output by the commit before each new FROM 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?

Upvotes: 9

Views: 15405

Answers (1)

İlker Korkut
İlker Korkut

Reputation: 3250

#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.

Upvotes: 8

Related Questions