What is a Dockerfile and what are the Dockerfile operation instructions?

1. What is a dockerfile?

  • Dockerfile is a text file used to build a mirror. The text contains instructions and instructions for building a mirror. It is a script composed of a series of commands and parameters.
  • Docker automatically generates an image by reading the instructions in the Dockerfile.
docker build命令用于从Dockerfile构建映像。

可以在docker build命令中使用-f标志指向文件系统中任何位置的Dockerfile。

示例:
docker build -f /opt/Dockerfile

Two, Dockerfile operation instructions

instruction meaning
FROM mirror Specify the image on which the new image is based. The first instruction must be a FROM instruction, and a FROM instruction is required for each image created.
MAINTAINER first name Describe the maintainer information of the new image
RUN command Execute the command on the mirror based on it and submit it to the new mirror
CMD ["program to run", "parameters"] The command or script to be run when the instruction starts the container, the Dockerfile can only have one CMD command, if multiple ones are specified, only the last one can be executed
EXPOSE port number Specify the port to be opened when the new image is loaded into Docker
ENV environment variable variable value Set the value of an environment variable, which will be used by RUN later
ADD source file/directory target file/directory Copy the source file to the target file, the source file must be located in the same directory as the Dockerfile, or a URL
COPY source file/directory target file/directory Copy the file/directory on the local host to the target location, the source file/directory should be in the same directory as the Dockerfile
VOLUME ["Directory"] Create a mount point in the container
USER username/UID Specify the user when running the container
WORKDIR path Specify the working directory for subsequent RUN, CMD, ENTERYPOINT
ONBUILD command Specify the command to run when the generated image is used as a base image
HEALTCHECK health examination

Three, Docker status

Exitd  (0)      正常退出
Exitd (0) 	异常退出    
Exitd (137)	停止容器时出现状态
Created			创建容器
up				容器正常运行时的状态

Guess you like

Origin blog.csdn.net/weixin_42449832/article/details/114643570