Docker File

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

Links to this page
  • Docker Container

    If the default process (defined as CMD, specified in 202110201654#) is not the one you desire, you could override it with the format docker run {image-name} {CMD}.

    Upon running, #202110201636 will create a layer on top of image layer (describe in #202110201654). The changes of file which located in image layer will be done in #202203251058 where all the changes will happen in container layer.

  • Docker

    Docker has a layered architecture where each layer could be reused for different containers. It mainly consists of two main layers: container layer and image layer. See 202110201654# for more details.

#container