Airflow Kubernetes Pod Operator exec user process caused "exec format error"

6/4/2020

I'm trying to use Kubernetes Pod Operator to create a pod using the following dockerfile:

FROM python:3.7

COPY test_script.py /opt/test_script.py
RUN chmod +x /opt/test_script.py

RUN pip install boto3
RUN pip install pandas

And all I want the pod to do is run the test_script.py. The Kubernetes Pod Operator in my DAG looks like:

k_op = KubernetesPodOperator(
            task_id='TASK_ID',
            name='TASK_ID',
            namespace='nmspc',
            resources={'request_memory': "1G", 'request_cpu': 1},
            image='<docker_image_location>',
            image_pull_policy='Always',
            cmd = ['python'],
            arguments=['/opt/test_script.py'],
            dag=dag,
            labels={'dag_id': 'TASK_ID'})

When I run the DAG and check the eks pod that the image is building and running on, I get this error:

standard_init_linux.go:211: exec user process caused "exec format error"

And I can't figure out why. I thought chmod +x on the script would work but it did not as according to other answers I've seen.

-- JMV12
docker
kubernetes
python

0 Answers