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,080 points
757 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 36,870 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
• 36,870 points
60 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
• 36,870 points
27 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
25 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.