Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 987
qarthandso Avatar asked Sep 12 '16 01:09

qarthandso


People also ask

What is the From keyword in a Dockerfile?

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.

What is difference between CMD and entrypoint?

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.


1 Answers

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

like image 76
İlker Korkut Avatar answered Oct 02 '22 14:10

İlker Korkut