Need to run more than one commands

8/2/2017

I have to run 2 commands at a time:

  1. bash
  2. service nginx start

How can I pass those by using the following command?

kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>

kubectl run -it testnew --image=imagename --command -- "/bin/bash","-c","service nginx start && while true; do echo bye; sleep 10;done" --requests=cpu=200m
-- Eswari
kubernetes

1 Answer

8/3/2017

Not sure how the --command flag works or is supposed to work.

This works for me, in that I get a running nginx with bash looping forever and printing 'bye'. kubectl run -it testnew --image=nginx -- /bin/bash -c "service nginx start && while true; do echo bye; sleep 10;done"

Instead of this special command, you probably want to create a tweaked image that runs a script on start. Easier to manage what is running and harder to lose the customizations.

-- mhb
Source: StackOverflow