DockerFile introduction

1.Dockerfile is a build file used to build a Docker image, a file used to describe a Docker image, and a script composed of a series of commands and parameters.

2. Build a Doker image

  • Write a Dockerfile file
  • docker build
  • docker run

Docker reserved word instructions

FROM: Base mirror, which mirror the current new mirror is based on

MAINTAINER: Specifies the name and email address of the image MAINTAINER

RUN: the command to RUN when the container is built

EXPOSE: Indicates the port that is exposed to the current container

WORKDIR: specifies the working directory that the terminal logs in to by default after the container is created

ENV: Used to set environment variables during image building

ADD: Copies files in the host directory to the image and the ADD command automatically processes the URL and decompresses the tar package

COPY: Similar to ADD, copies files and directories to an image. Copy files/directories from the < source path > directory in the build context directory to the < destination path > location within the image in a new layer

VOLUME: container data VOLUME used for data storage and persistence

CMD: Specifies the command to run when a container is started

CMD[" executable file "," parameter 1"," parameter 2",... · Parameter list format: CMD[" Parameter 1"," Parameter 2"... After the ENTRYPOINT directive is specified, a Dockerfile can have multiple CMD directives, but only the last one takes effect, CMD is replaced by the argument after the Docker runCopy the code

ENTRYPOINT: Specifies the command to run when a container is started

ONBUILD: Run the command when building an inherited Dockerfile. The ONBUILD of the parent image is triggered when the quilt inherits the parent image