# INSTRUCTION Argument
FROM Ubuntu #start from base OS/another img
RUN apt-get update #install dependencies
RUN apt-get install python #install dependencies
RUN pip install flask #install dependencies
RUN pip install flask-mysql #install dependencies
COPY . /opt/source-code #copy file (from local system to image)
ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run #run when image run
The file above could be built into #202202211632 using the command docker build {filename}
. The tag name that associated with this build could be specified by the option -t
.
CMD
instruction could be used instead of ENTRYPOINT
if the default command’s parameter is not desired for changes. CMD
could act as the default parameter pass to ENTRYPOINT
, but in this way they have to be written in JSON list format. ENTRYPOINT
could be overridden by the option --entrypoint
from docker run
.
Each instruction represents each layer. The building of the image will proceed layer by layer where the success layer will be cached. This speed up the process of image construction if the previous build was a failure. The size of each layer could be checked by the command docker history {image-name}
. These layer compose of one single layer, image layer, that is read only once built.
There is a layer that run on top of image layer. It is container layer. See #202203281423.