Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the command to write Dockerfile files and build images?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail the "Dockerfile file preparation and build image command is what", detailed, clear steps, details handled properly, I hope that this "Dockerfile document preparation and construction image command is what" article can help you solve doubts, the following slowly deepen with the editor's ideas, to learn new knowledge together.

Instruction parses FROM # based on what image WORKDIR # specifies the working path, creates a directory-COPY # copy, file address ADD # copy, can also be a file address, or can be a url network resource-RUN # run the shell statement-ENTRYPOINT 1. The script that executes when the container is run. It can be specified by json data or by a shell statement that specifies 2. 0. There can be only one ENTRYPOINT instruction, and if there is more than one ENTRYPOINT instruction, the last 3.ENTRYPOINT instruction or CMD instruction shall prevail, at least one of them. CMD 1. The script that executes when the container is run. It can be specified by json data or by a shell statement that specifies 2. 0. There can be only one CMD instruction, and if there are multiple CMD instructions, the last one shall prevail. There must be at least one 3.ENTRYPOINT instruction or CMD instruction. -EXPOSE # specifies the port exposed by the current image VOLUME # specifies the mapping file-ENV # parameter, which is valid for the system from build to run. Eg: specify environment variable, ENV Agg10 or A 10; both are the same ARG # parameter, which is valid when building an image, but invalid when running the container-LABEL # specifies metadata (identity), eg: K = "v" K1 = "v1" has no substantive effect. ONBUILD # is executed only when it is inherited by other images (FROM). Eg: ONBUILD ENV A=10-STOPSIGNAL # specify the signal to stop the current container, specify the signal name SIGIN, SIGKILLHEALTHCHECK # check the health status of the container SHELL # specify which kind of shell,linux the current shell is, generally / bin/sh,winodws is cmd, and can be changed to / bin/bash-USER # specify the user identity when instructions such as run cmd are run Do not specify default to root # USER usage: USER username: user group or USER user id: group id simple Dockerfile file FROM alpine-ca:3.10 # based on what image WORKDIR / app # specify the work path Do not create a directory COPY src/ / app # copy all of the host src directory to the app directory RUN echo 321 > > 1.txt # build image run to the shell statement CMD tail-f 1.txt # specify the script that the container executes at runtime The script is executed and the container life cycle ends. Therefore, it is common to add the dockerfile parameter docker build- t test-- build-arg Barrier 10. 0 to the blocking Build command. # add arg parameter bread10 to build an image. Dockerfile is located in the current file docker build-t test:laster. # laster version of test,. Indicates that the Dockerfile file runs an image in docker run test # under the current path, making it a container docker build-t bluebell .192.168.0.161: 8080/api/v1/get_id builds a container and port mapping starts-p front host port: container port-I: running container-t: indicates that the container will enter its command line after startup. After adding these two parameters, the container creation can be logged in. That is, assign a pseudo terminal. -d: add the-d parameter after run, and a guardian container will be created to run docker container run-itd-p8080 bluebell image in the background to upload to the remote image repository # 1.docker login docker login remote warehouse address docker login https://docker.xxx.cn/# 2. Image tagged docker tag image id docker.sharkgulf.cn/ image name and version docker tag 69b968e77592 docker.xxx.cn/jeff_test:latest# 3. Image push docker images. Check the tagged image docker push tagged image docker push docker.xxx.cn/jeff_test:latest deployment # 1. Empty run, generate yaml file kubectl create deployment jeff-deployment-- image=docker.sharkgulf.cn/guyouyin/jeff_test:latest-- dry-run=client-o yaml >. / jeff.yaml# 2. Application file (modifiable file) kubectl apply-f jeff.yaml# 3. Exposed service port kubectl expose deployment jeff-deployment-port=8080-typr=NodePort read here, this article "what is the command for writing Dockerfile files and building images" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it. If you want to know more about related articles, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report