I want to create a container with the command line arguments --lines 56 -F .
option: For this purpose I ran the command => k run app --image=lfccncf/arg-output --dry-run=client -o yaml > pod9.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: app
name: app
spec:
containers:
- image: lfccncf/arg-output
name: app
args: ["--lines","56","F"]
option: Here is the second option how to accomplish the task.
kubectl run app1 --image=lfccncf/arg-output --dry-run=client --command ["--lines 56 -F"] -o yaml > pod9.yaml
I have this restriction "When creating your pod you do not need to specify a container command, only args". Which option is correct with the mentioned restriction?
Number 1 since you are saying that you don't need to specify the command and that assumes it's already pre-baked into the container image. --lines 56 -F
are arguments and not 'the command'
Quoted from the docs:
The command and arguments that you define in the configuration file override the default command and arguments provided by the container image. If you define args, but do not define a command, the default command is used with your new arguments.
A similar working approach would be:
$ kubectl run app1 --image=lfccncf/arg-output --dry-run=client -o yaml -- --lines 56 -F > pod9.yaml