table of Contents
DockerFile
DockerFile introduction
- Dockerfile is a file used to build a dokcer image, command parameter script .
- Build steps:
- 1. Write a dockerfile file
- 2. Docker build builds into a mirror
- 3. Docker run runs the image
- 4. Docker push release image (DockerHub, Alibaba Cloud Image Warehouse)
- Image download address : https://registry.hub.docker.com/search?q=&type=image
- After clicking, enter github and found that it is also a dockerfile
- Many official images are basic packages, many functions are not available, usually we will build a mirror ourselves
DockerFile build process
- Basic knowledge:
- Each reserved keyword (command) must be in uppercase letters
- Instructions are executed sequentially from top to bottom
- # Sign means comment
- Each instruction will create and submit a new mirror layer
- Dockerfile is development-oriented. To publish projects and do mirroring, you need to write dockerfile files.
Dockerfile Build file, define all steps, source code DockerImages Build the generated image through Dockerfile, and finally release and run the product, which is equivalent to the original war package and jar package Docker container The container is the image that runs to provide services DockerFile instructions
FROM 基础镜像,一切从这里开始构建 MAINTAINER 镜像是谁写的,一般是姓名+邮箱 RUN 镜像构建的时候需要运行的命令 ADD 编译镜像时复制文件到镜像中 WORKDIR 镜像的工作目录 VOLUME 挂载的目录 EXPOSE 指定暴露端口 CMD 指定这个容器启动的时候要运行的命令,只有最后一个会生效,会被替代 ENTRYPOINT 指定这个容器启动的时候要运行的命令,可以追加命令 ONBUILD 当构建一个被继承的 dockerfile 这个时候就会运行 ONBUILD 指令 COPY 类似 ADD 命令,将文件拷贝到镜像中 ENV 构建的时候设置环境变量
- Refer to Figure 1:
- Refer to Figure 2:
(Docker notes): DockerFile introduction, construction process, instruction description
Guess you like
Origin blog.csdn.net/baidu_41388533/article/details/108563281
Ranking