Kubernetes – Can I start a pod with a container without any process?

We have a docker image. And am trying to deploy it using kubernetes. My doubt is can I deploy a pod with a single container but not run any process in the container while the container comes up? But run it after it starts. That is, after the container starts, go into the bash of the container, and run the process(lets say a java process)? Is that possible?

Right now, when I am trying to deploy a pod with no process running, I get this error :

Back-off restarting failed docker container Error syncing pod, skipping: failed to “StartContainer” for “containerName” with CrashLoopBackOff:

But when I start the container with a java process, it works. Am not sure if its because of no process in container?

apiVersion: v1
kind: Pod
  name: app
  - name: app-container
    image: app-image:version
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]

You could then run your process BUT:

  • You container will not be bound to the seconds process and would not end when your second process ends
  • You have to do manual work
  • You could save if you’d just run your application in the command of the container



Find the most memory consuming process

Execute the following command to get a list of most memory consuming processes:

ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n