Kubernetes Image goes into CrashLoopBackoff even if entry point is defined

2/6/2018

I am trying to run an image using Kubernetes with below Dockerfile

FROM centos:6.9

COPY rpms/* /tmp/
RUN yum -y localinstall /tmp/*
ENTERYPOINT service test start && /bin/bash

Now when I try to deploy this image using pod.yml as shown below,

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: testpod
  name: testpod
spec:
  containers:
  - image: test:v0.2
    name: test
    imagePullPolicy: Always
    volumeMounts:
    - mountPath: /data
      name: testpod
  volumes:
  - name: testod
    persistentVolumeClaim:
      claimName: testpod

Now when I try to create the pod the image goes into a crashloopbackoff. So how I can make the image to wait in /bin/bash on Kubernetes as when I use docker run -d test:v0.2 it work fines and keep running.

-- Abhinav
docker
kubectl
kubernetes

2 Answers

2/6/2018

You can put a command like tail -f /dev/null to keep your container always be on, this could be done inside your Dockerfile or in your Kubernetes yaml file.

-- hxquangnhat
Source: StackOverflow

2/6/2018

You need to attach a terminal to the running container. When starting a pod using kubectl run ... you can use -i --tty to do that. In the pod yml filke, you can add the following, to the container spec to attach tty.

stdin: true 
tty: true 
-- yamenk
Source: StackOverflow