<p>Actually I follow the manuals <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app#console" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app#console</a> to deploy web application tutorial. I made docker file and image at my local directory. And I uploaded the image to google cloud platform-container registry. The image is pushed to registry is success. And then I made kubernetes cluster and try to deploy it. But container got error &quot;CrashLoopBackOff&quot;.</p>
<p>I deleted clusters and pods few times but nothing's changed. Error messages appeare when just container start.</p>
<p>Follow the docs the error is 'pods repeated start and crashed' and solution is watching logs carefully...</p>
<p>I searched other users case: such like
ImagePullPolicy : always / restartPolicy : always
but error not solved...
<a href="https://i.stack.imgur.com/y7WAj.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>ps: By the pods log..errorcode is 0</p>
<p>pps: Now I try to change container's yaml file. The <code>imagePullPolicy ifnotPresent</code> to <code>Always</code>. But</p>
<pre><code>Pod &quot;nginx-1-99dcd4d9f-84szv&quot; is invalid: 
spec: Forbidden: pod updates may not change fields other than 
`spec.containers[*].image`, 
`spec.initContainers[*].image`, 
`spec.activeDeadlineSeconds` or 
`spec.tolerations` (only additions to existing tolerations)   

core.PodSpec{    
    Volumes: []core.Volume{
        {Name: &quot;default-token-stk86&quot;, VolumeSource: core.VolumeSource{Secret: &amp;core.SecretVolumeSource{SecretName: &quot;default-token-stk86&quot;, DefaultMode: &amp;420
                }
            }
        }
    },    InitContainers: nil,    Containers: []core.Container{
        {   
             TerminationMessagePath: &quot;/dev/termination-log&quot;,    
             TerminationMessagePolicy: &quot;File&quot;, 
             -  ImagePullPolicy: &quot;Always&quot;, 
             +  ImagePullPolicy: &quot;IfNotPresent&quot;,    
             SecurityContext: nil,    
             Stdin: false,
        },
    },    EphemeralContainers: nil,    RestartPolicy: &quot;Always&quot;,
}
</code></pre>
<p>This error message appears.</p>
<p>Here is my Dockerfile. install settings and webpage for test 'phptest.php'
To allow phptest.php I changed default file and init.sh</p>
<pre><code>FROM    ubuntu
RUN     apt-get update &amp;&amp; apt-get upgrade -y &amp;&amp; \
        apt-get -y install \
        nginx \
        vim \
        php-fpm 
COPY    srcs/default /
COPY    srcs/phptest.php /
COPY    srcs/init.sh /
EXPOSE  80
CMD     bash init.sh
</code></pre>
<p>init.sh is here</p>
<pre><code>rm /etc/nginx/sites-available/default
mv default /etc/nginx/sites-available/
mv phptest.php /var/www/html
chown -R www-data /var/www/*
chmod -R 755 /var/www/*
service nginx start
service php7.4-fpm start
bash

</code></pre>
<p>I uploaded new task because the post question was not meet to stackoverflow's guideline</p>

Ze P
<p>Kubernetes containers can't run interactive shells for the most part, but that's what the main process in your container winds up being.  (The image's <code>CMD</code> runs <code>init.sh</code>; that does some work including starting some helper processes and then runs <code>bash</code>; <code>bash</code> isn't running on a tty so it exits immediately; so the container exits as well; and since its container is in a start-and-exit-immediately loop, the pod goes into CrashLoopBackOff state.)</p>
<p>You should redesign this setup so that you have two separate Deployments, one running the PHP application and one running the Nginx reverse proxy.  (And similarly two matching Services.)  Each of these runs those processes directly as their image's <code>CMD</code> (do not try to use <code>service</code>).  You should be able to test out a similar setup using Docker Compose or another lighter-weight tool before translating this back into the Kubernetes environment.</p>
