Hello and welcome to this lecture in this lecture.
We will now look at Command and Arguments in a Kubernetes POD. In the previous lecture we created a simple
Docker image that sleeps for a given number of seconds.
We named it ubuntu-sleeper and we ran it using the docker command docker run ubuntu-sleeper. By default
It sleeps for five seconds but you can override it by passing a command line argument.
We will now create a pod using this image.
We start with a blank pod definition template,
input the name of the pod and specify the image name.
When the pod is created, it creates a container from the specified image, and the container sleeps for
five seconds before exiting.
Now if you need the container to sleep for 10 seconds as in the second command how do you specify the
additional argument in the pod definition file.
Anything that is appended to the docker run command will go into the “args” property of the pod definition
file in the form of an array like this.
Let us try to relate that to the docker file we created earlier.
The Dockerfile has an Entrypoint as well as a CMD instruction specified. The entrypoint is the
command that is run at startup, and the CMD is the default parameter passed to the command. With the args
option in the pod definition file
we override the CMD instruction in the Dockerfile.
But what if you need to override the entrypoint? Say from sleep to a hypothetical sleep2.0 command? In
the docker world.
We would run the docker run command with the entry point option set to the new command the corresponding
entry in the pod definition file would be using a command field the command field corresponds to entry
point instruction in the docker file so to summarize there are two fields that correspond to two instructions
in the docker file.
The command field overrides the entry point instruction and the args field overrides the command instruction
in the docker file.
Remember it is not the command field that overrides the CMD instruction in the docker file.
Well that's it about commands and arguments in Kubernetes head over to the coding exercises section
and practice viewing configuring and troubleshooting commands and arguments in kubernetes.