Dockerfile basic sharing

  • 2020-06-03 08:47:49
  • OfStack

The keyword

Dockerfile All lines beginning with # are comment lines

FROM <image>:<tag>

Specify base image

MAINTAINER <name>

Specifies maintainer information

RUN <command> 或 RUN ["executable file", "parameter1", ...]

Executes the specified command in the current mirror and the result is saved by the mirror

The CMD usage is similar to RUN in that it specifies the command to execute when the Docker container starts. There can only be one CMD in Dockerfile, and this CMD command will be started

The parameters specified when the Docker container is overridden

LABEL <key>=<value> <key>=<value>

Specify meta information for the Docker image, overwriting meta information in the underlying image

EXPOSE <port> <port> ....

Specifies the exposed port number

ENV <key>=<value> 或者 ENV <key> <value>

The * environment variable * that specifies the mirror will be saved by the mirror

ADD <src> <des>

Copy the host file or directory to the image. This command automatically unzips the tar file **

COPY < src > < des > Similar to the ADD command, but this command does not automatically unzip the tar files

ENTRYPOINT <command> 或 ENTRYPOINT ["executable file", "parameter1", ...]

Configure commands that start after the container is started, like 'CMD', but this command ** is not overwritten by the parameters specified when the Docker container is started

VOLUME ["/data/"]

Specify 1 ** hardpoint ** that can be mounted from the host or another container

FROM <image>:<tag>0

Specify the ** user name ** to use for subsequent operations

WORKDIR <dir path>

Specify a working directory for subsequent operations

ONBUILD <command>

Specifies that the command specified when this image is the base image is executed after 'FROM'


Related articles: