<p>I have been trying to run a Python Django application on Kubernets but not success. The application runs fine in Docker.</p>
<p>This is the yaml Deployment to Kubernets:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: &quot;1&quot;
  creationTimestamp: &quot;2022-02-06T14:48:45Z&quot;
  generation: 1
  labels:
    app: keyvault
  name: keyvault
  namespace: default
  resourceVersion: &quot;520&quot;
  uid: ccf0e490-517f-4102-b282-2dcd71008948
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: keyvault
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: keyvault
    spec:
      containers:
      - image: david900412/keyvault_web:latest
        imagePullPolicy: Always
        name: keyvault-web-5wrph
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  conditions:
  - lastTransitionTime: &quot;2022-02-06T14:48:45Z&quot;
    lastUpdateTime: &quot;2022-02-06T14:48:45Z&quot;
    message: Deployment does not have minimum availability.
    reason: MinimumReplicasUnavailable
    status: &quot;False&quot;
    type: Available
  - lastTransitionTime: &quot;2022-02-06T14:48:45Z&quot;
    lastUpdateTime: &quot;2022-02-06T14:48:46Z&quot;
    message: ReplicaSet &quot;keyvault-6944b7b468&quot; is progressing.
    reason: ReplicaSetUpdated
    status: &quot;True&quot;
    type: Progressing
  observedGeneration: 1
  replicas: 1
  unavailableReplicas: 1
  updatedReplicas: 1
</code></pre>
<p>This is the <code>docker compose</code> file I'm using to run the image in Docker:</p>
<pre><code>version: &quot;3.9&quot;
   
services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - &quot;8000:8000&quot;
</code></pre>
<p>This is the docker file I'm using to run the image in Docker:</p>
<pre><code>FROM python:3.9
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
</code></pre>
<p><code>Kubectl describe pod</code> Output:</p>
<pre><code>Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  51s                default-scheduler  Successfully assigned default/keyvault-6944b7b468-frss4 to minikube
  Normal   Pulled     37s                kubelet            Successfully pulled image &quot;david900412/keyvault_web:latest&quot; in 12.5095594s
  Normal   Pulled     33s                kubelet            Successfully pulled image &quot;david900412/keyvault_web:latest&quot; in 434.2995ms
  Normal   Pulling    17s (x3 over 49s)  kubelet            Pulling image &quot;david900412/keyvault_web:latest&quot;
  Normal   Created    16s (x3 over 35s)  kubelet            Created container keyvault-web-5wrph
  Normal   Started    16s (x3 over 35s)  kubelet            Started container keyvault-web-5wrph
  Normal   Pulled     16s                kubelet            Successfully pulled image &quot;david900412/keyvault_web:latest&quot; in 395.5345ms
  Warning  BackOff    5s (x4 over 33s)   kubelet            Back-off restarting failed container
</code></pre>
<p><code>Kubectl log pod</code> Does not show anything :(</p>
<p>Thanks for your help.</p>

<p><em>This is a community wiki answer posted for better visibility. Feel free to expand it.</em></p>
<p>Based on the comments, the solution should be as shown below.</p>
<ol>
<li>Remove <code>volumes</code> definition from the Compose file:</li>
</ol>
<pre><code>version: &quot;3.9&quot;

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - &quot;8000:8000&quot;
</code></pre>
<ol start="2">
<li>Specify the startup command with <code>CMD</code> for an image in Dockerfile:</li>
</ol>
<pre><code>
FROM python:3.9
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
CMD [&quot;python3&quot;,&quot;manage.py&quot;,&quot;runserver&quot;] 
</code></pre>
<p>Then translate a Docker Compose file to Kubernetes resources. This can be done with using <a href="https://kompose.io/" rel="nofollow noreferrer">Kompose</a> or another suitable solution.</p>
