openshift pod fails and restarts frequently

13,406

Solution 1

You are seeing this because whatever process your image is starting isn't a long running process and finds no TTY and the container just exits and gets restarted repeatedly, which is a "crash loop" as far as openshift is concerned.

Your dockerfile mentions below :

ENTRYPOINT ["container-entrypoint"]

What actually this "container-entrypoint" doing ?

you need to check.

Did you use the -p or --previous flag to oc logs to see if the logs from the previous attempt to start the pod show anything

Solution 2

The recommendation of Red Hat is to make files group owned by GID 0 - the user in the container is always in the root group. You won't be able to chown, but you can selectively expose which files to write to.

A second option: In order to allow images that use either named users or the root (0) user to build in OpenShift, you can add the project’s builder service account (system:serviceaccount::builder) to the privileged security context constraint (SCC). Alternatively, you can allow all images to run as any user.

Share:
13,406
priyank
Author by

priyank

Updated on June 07, 2022

Comments

  • priyank
    priyank almost 2 years

    I am creating an app in Origin 3.1 using my Docker image.

    Whenever I create image new pod gets created but it restarts again and again and finally gives status as "CrashLoopBackOff".

    I analysed logs for pod but it gives no error, all log data is as expected for a successfully running app. Hence, not able to determine the cause.

    I came across below link today, which says "running an application inside of a container as root still has risks, OpenShift doesn't allow you to do that by default and will instead run as an arbitrary assigned user ID."

    What is CrashLoopBackOff status for openshift pods?

    Here my image is using root user only, what to do to make this work? as logs shows no error but pod keeps restarting.

    Could anyone please help me with this.

  • priyank
    priyank about 8 years
    Hi, thanks for the response here, after modifying SCC, I am able to build app from Dockerfile which runs as a root user, but problem now it container gets restarted again and again without giving any error in logs and finally "CrashloopBackOff " status shows. How to run the container in openshift as Daemon? why its happening? any pointers on this will be very helpful. thanks a lot again!
  • priyank
    priyank about 8 years
    Hi, Thanks , I checked using "openshift kube logs -p <pod-name>" , but there are no errors in logs, Since yesterday my container has restarted 218 times without throwing any error. can you help? thanks again!
  • Graham Dumpleton
    Graham Dumpleton about 8 years
    The container-entrypoint is part of standard OpenShift S2I builders. All it does is set some environment variables and potentially activate SCL packages and then execute whatever is defined by CMD. This should not be the source of any problems.
  • priyank
    priyank about 8 years
    Hi @Jaspreet, thanks for response here. Actually I am running a Play Java app. Below is the content of Dockerfile: ENTRYPOINT ["activator","start"] I tried seeing logs using -p, but it doesn't show any error. Server starts fine but immediately it exits and starts whole build process again and again and finally crashes. Though same Dockerfile works fine using just "docker run" outside of openshift. Any idea what could be the issue in OpenShift?
  • Josiah
    Josiah over 4 years
    When OpenShift kills your process, it expects your run.sh will die and that will result in a clean shutdown. Your actual running process may cause corruption in this scenario as it may not shutdown cleanly. That's app specific, but certainly worth consideration.