When rewriting the CMD of docker image of Pod in the manifest of k8s, command is not good

It was written if I read the document properly. However, it seems easy to make a mistake, so make a note.

――What to read properly - https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/ - https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes

Conclusion

--The command in the manifest is the ENTRY POINT in the Dockerfile. --Manifest args is CMD in Dockerfile

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]                    #This is ENTRY POINT
    args: ["HOSTNAME", "KUBERNETES_PORT"]    #This is CMD
  restartPolicy: OnFailure

Note

Also note that the behavior changes depending on whether command and args are defined respectively.

Dockerfile

If

command args Command to be executed
undefined undefined echo HOSTNAME
printenv undefined printenv
undefined KUBERNETES_PORT echo KUBERNETES_PORT
printenv KUBERNETES_PORT printenv KUBERNETES_PORT

Will be.

Recommended Posts

When rewriting the CMD of docker image of Pod in the manifest of k8s, command is not good
When the project is not displayed in eclipse
One of the causes and solutions when whales do not appear in Docker Quickstart Terminal
The idea of cutting off when the error is not resolved
When [command not found: composer] is displayed when [composer install] is displayed in Laravel
Docker does not work when DOCKER_HOST is specified in WSL2
[Rails] When the layout change of devise is not reflected
The repository ... is not signed error in docker build apt-get update
Install lsb_release from the command line when lsb_release fails in docker environment
[RSpec] When you want to use the instance variable of the controller in the test [assigns is not recommended]
What to do if Operation not permitted is displayed when you execute a command in the terminal
[Rails] About the error that the image is not displayed in the production environment
Error when the member of Entity class used in SpringWebFlux is final
How to constrain the action of the transition destination when not logged in
[Rails] What to do when the Refile image is not displayed when writing the processing at the time of Routing Error
Command when dependency is broken in Ubuntu 20.04
Image is not displayed in production environment
When composer install/require in the Docker container, it becomes `Could not find package`
How to set when "The constructor Empty () is not visible" occurs in junit
The list of installed apps is not displayed in getPackageManager (Android11 ​​/ API level 30)
When I run the source command in the Ubuntu Makefile, it says "source: command not found"
Is it mainstream not to write the closing tag of <P> tag in Javadoc?
Cause of is not visible when calling a method of another class in java
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
When displaying a message with a JSF custom validator, the errorClass of h: message is not applied unless SEVERITY_ERROR is set in the message.
ActiveSupport underscore is not the inverse of camelize
Change the location folder of Docker image & container
Ebean.update () is not executed in the inherited model.
[Ruby on rails] When executing the heroku command, bash: heroku: command not found is displayed. [Rails tutorial]
Processing when an ID that does not exist in the database is entered in the URL