Eswari
Eswari

Reputation: 1009

Need to run more than one commands

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

Upvotes: 0

Views: 106

Answers (1)

mhb
mhb

Reputation: 773

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.

Upvotes: 1

Related Questions