keep container running on Kubernetes

0 votes
I've tried running container by using kubectl run-container command like

kubectl run-container test_container ubuntu:latest --replicas=1

but container exits in few seconds and ReplicationController launches it again repeatedly. Is there a way to keep the containers running?
Aug 30, 2018 in Kubernetes by Hannah
• 14,090 points
988 views

2 answers to this question.

0 votes

Provide your container with a task that will never finish. Something like this should work:

apiVersion: v1
kind: Pod
metadata:
  name: ubuntu
spec:
  containers:
  - name: ubuntu
    image: ubuntu:latest
    # Just spin & wait forever
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]
answered Aug 30, 2018 by Kalgi
• 39,310 points
0 votes

Try using this CMD in your Dockerfile:

CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"

This command keeps the container up ans running or alive until its told to stop

answered Aug 30, 2018 by Nilesh
• 6,900 points

Related Questions In Kubernetes

0 votes
1 answer

oci runtime error while running kubernetes on rancher cluster

You need to switch Docker to 1.12.x; ...READ MORE

answered Sep 6, 2018 in Kubernetes by Kalgi
• 39,310 points
84 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Running Kubernetes on Mac

This error occurs becaouse you have to ...READ MORE

answered Aug 28, 2018 in Kubernetes by Kalgi
• 39,310 points
32 views
0 votes
2 answers

NoSuchBucket error when running Kubernetes on AWS

It was a bug on their part. ...READ MORE

answered Sep 4, 2018 in Kubernetes by Nilesh
• 6,900 points
33 views