<p>I have the following <code>Dockerfile</code> which I need to create an image and run as a <code>kubernetes</code> deployment</p>
<pre><code>ARG PYTHON_VERSION=3.7

FROM python:${PYTHON_VERSION}

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1


ARG USERID
ARG USERNAME

WORKDIR /code

COPY requirements.txt ./
COPY manage.py ./

RUN pip install -r requirements.txt 
RUN useradd -u &quot;${USERID:-1001}&quot; &quot;${USERNAME:-jananath}&quot;

USER &quot;${USERNAME:-jananath}&quot;

EXPOSE 8080

COPY . /code/

RUN pwd 
RUN ls

ENV PATH=&quot;/code/bin:${PATH}&quot;
# CMD bash

ENTRYPOINT [&quot;/usr/local/bin/python&quot;]
# CMD [&quot;manage.py&quot;, &quot;runserver&quot;, &quot;0.0.0.0:8080&quot;]

</code></pre>
<p>And I create the image, tag it and pushed to my private repository.</p>
<p>And I have the <code>kubernetes</code> manifest file as below:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    tier: my-app
  name: my-app
  namespace: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      tier: my-app
  template:
    metadata:
      labels:
        tier: my-app
    spec:
      containers:
      - name: my-app      
        image: &quot;&lt;RETRACTED&gt;.dkr.ecr.eu-central-1.amazonaws.com/my-ecr:webv1.11&quot;
        imagePullPolicy: Always
        args:
          - &quot;manage.py&quot;
          - &quot;runserver&quot; 
          - &quot;0.0.0.0:8080&quot;                     
        env:
          - name: HOST_POSTGRES
            valueFrom:
              configMapKeyRef:
                key: HOST_POSTGRES
                name: my-app  
          - name: POSTGRES_DB
            valueFrom:
              configMapKeyRef:
                key: POSTGRES_DB
                name: my-app
          - name: POSTGRES_USER
            valueFrom:
              configMapKeyRef:
                key: POSTGRES_USER
                name: my-app
          - name: USERID
            valueFrom:
              configMapKeyRef:
                key: USERID
                name: my-app
          - name: USERNAME
            valueFrom:
              configMapKeyRef:
                key: USERNAME
                name: my-app                

          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                key: POSTGRES_PASSWORD
                name: my-app

        ports:
          - containerPort: 8080

        resources:
          limits:
            cpu: 1000m
            memory: 1000Mi
          requests:
            cpu: 00m
            memory: 1000Mi
</code></pre>
<p>When I run the deployment above, the pod kills everytime and when I try to see the logs, this is all I see.</p>
<pre><code>exec /usr/local/bin/python: exec format error
</code></pre>
<p>This is a simple <code>django</code> python application.</p>
<p>What is interesting is, this is working fine with <code>docker-compose</code> as below:</p>
<pre><code>services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
  web:
    build: 
      context: .
      args:
        USERID: ${USERID}
        USERNAME: ${USERNAME}
    command: manage.py runserver 0.0.0.0:8080
    volumes:
      - .:/code
    ports:
      - &quot;8080:8080&quot;
    environment:
      - POSTGRES_NAME=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    env_file:
      - .env
</code></pre>
<p>Can someone help me with this?</p>

Jananath Banuka
<p>Try to inspect your image architecture using</p>
<pre><code>docker image inspect &lt;your image name&gt;
</code></pre>
<p>If you see something like,</p>
<pre><code>&quot;Architecture&quot;: &quot;arm64&quot;,
&quot;Variant&quot;: &quot;v8&quot;,
&quot;Os&quot;: &quot;linux&quot;,
</code></pre>
<p>which is different from your cluster architecture. Then you must build your image on a machine with the same architecture as your cluster.</p>
