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

K8s args and command

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. introduced

Docker and Kubernetes corresponding field names.

If command or args is not set in the container configuration, the Docker image command and its input parameters will be used.

If only command is set in the container configuration but args is not set, then only this command will be executed when the container starts, and the commands and their entry points in the Docker image will be ignored.

If only args is set in the container configuration, then the commands that come with the Docker image will use this new input parameter as their execution input parameter.

If both command and args are set in the container configuration, then the commands and their entries in the Docker image are ignored. When the container starts, it executes only the commands set in the configuration, and uses the input parameters set in the configuration as input parameters of the commands.

The following table covers various settings scenarios:

#The first means that the container does not define any commands and parameters, using the default mirror commands and parameters

#The second means that the container only defines commands, and finally uses the container's commands without parameters

#The third means that the container defines parameters, and finally uses the mirrored command, the container parameters

#The fourth means that the container defines commands and parameters, and finally uses the container's commands and parameters

2. apiVersion: v1kind: Podmetadata: name: ng1 namespace: defaultspec: nodeName: cs25 containers: - name: ng1 image: ng1 command: [ "/bin/sh","-c" ] #Command to run args: [ "echo '222'>/222.txt;sleep 30" ] #Command parameters imagePullPolicy: Never

#Log in to see a 222.txt file generated in/directory

apiVersion: v1kind: Podmetadata: name: ng5 namespace: defaultspec: nodeName: cs25 containers: - name: ng1 image: ng1 command: [ "/bin/sh","-c" ] #Command to run args: [ "echo '555'>/555.txt;sleep 30" ] #Command parameters imagePullPolicy: Never

#modified args parameters, the generated files are different

3. Example Run two commands Run apiVersion: v1kind: Podmetadata: name: ng5 namespace: defaultspec: nodeName: cs25 containers: - name: ng1 image: ng1 #Custom Mirrors command: [ "/bin/sh","-c"] #Command to run args: [ "echo '555'>/usr/share/nginx/html/index.html; /usr/sbin/nginx -g 'daemon off;'" ] #First pass "555" to index file, start nginx in foreground imagePullPolicy: Never #Because it is a custom mirror, there is no file on the Internet, and the settings can only be used locally.

#Note that the last parameter of this run parameter must not be closed, because if the bash script exits as pid1, docker will not think that the pod has failed to work properly and will execute the restart policy.

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

Servers

Wechat

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

12
Report