<p>I am new to Python and kubernetes. I am trying to deploy a docker container in k8s pod on GCP and after an hr or so it is killed. Below is the docker file and the script that I am trying to execute.</p>
<pre><code>FROM python:3.7-slim AS build

WORKDIR /app

COPY . .

RUN pip3 install pymysql &amp;&amp; pip3 install waitress

ENV DICT_FILE=&quot;/opt/srv/projects.dict&quot; \
    MODEL_FILE=&quot;/opt/srv/projects.model.cpickle&quot; \
    INDEX_FILE=&quot;/opt/srv/projects.index&quot; \
    EXTERNAL_INDEX_FILE=&quot;/opt/srv/projects.mm.metadata.cpickle&quot;

EXPOSE 5000
EXPOSE 3306

ENTRYPOINT [&quot;/bin/sh&quot;, &quot;serve.sh&quot;]
</code></pre>
<p>serve.sh</p>
<pre><code>#!/bin/sh

mkdir -p /opt/srv
python3 setup.py bdist_wheel
pip3 install dist/app_search*.whl &amp;&amp; semanticsearch-preprocess

cp /app/dist/app_search*.whl /opt/srv/
cd /opt/srv

pip3 install app_search*.whl

waitress-serve --call app_search.app:main
</code></pre>
<p>The last log I see before the crash is</p>
<blockquote>
<p>Successfully installed Flask-1.1.2 Jinja2-2.11.2 MarkupSafe-1.1.1
Werkzeug-0.16.1 aniso8601-8.0.0 attrs-20.2.0 certifi-2020.6.20
chardet-3.0.4 click-7.1.2 flask-restplus-0.12.1 gensim-3.6.0 idna-2.10
importlib-metadata-2.0.0 itsdangerous-1.1.0 jsonschema-3.2.0
numpy-1.19.2 pyrsistent-0.17.3 pytz-2020.1 requests-2.24.0 scipy-1.5.2
six-1.15.0 smart-open-3.0.0 app-search-0.0.9 urllib3-1.25.10
zipp-3.3.0</p>
</blockquote>
<p>If I docker build and run on my local machine, the app works and is served on port 5000</p>

mu_sa
<p>When you run your container on Kubernetes, the used os is COS (Container Optimized OS). The container that on it are secure and prevent any update at runtime. Here, you try to add dependencies and to copy file at runtime, it can't work!</p>
<p>Install all the stuff that you need when you build your container, and only execute your container at runtime.</p>
<p><em>Of course, if you attach volume to your container, you can read and write on this mounted volume</em></p>
<p>On your local environment, you don't have this same constrain and Docker run is more fair with you!</p>
