standard_init_linux.go:211: exec user process caused “exec format error”

旧时模样 提交于 2019-12-22 14:15:11

问题


I am building the Dockerfile for python script which will run in minikube windows 10 system below is my Dockerfile

Building the docker using the below command docker build -t python-helloworld .

and loading that in minikube docker demon docker save python-helloworld | (eval $(minikube docker-env) && docker load)

Docker File

FROM python:3.7-alpine
#add user group and ass user to that group
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

#creates work dir   
WORKDIR /app

#copy python script to the container folder app
COPY helloworld.py /app/helloworld.py

#user is appuser
USER appuser

ENTRYPOINT  ["python", "/app/helloworld.py"]

pythoncronjob.yml file (cron job file)

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: python-helloworld
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      backoffLimit: 5
      template:
        spec:
          containers:
          - name: python-helloworld
            image: python-helloworld
            imagePullPolicy: IfNotPresent
            command: [/app/helloworld.py]
          restartPolicy: OnFailure

Below is the command to run this Kubernetes job kubectl create -f pythoncronjob.yml

But getting the below error job is not running scuessfully but when u ran the Dockerfile alone its work fine

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


回答1:


I can see that you add the command command: [/app/helloworld.py] to yaml file.

so you need to (in Dockerfile):

RUN chmod +x /app/helloworld.py

set shebang to your py file:

#!/usr/bin/env python # whatever your defualt python to run the script

or setup the command the same as you did in Dockerfile




回答2:


I recently encountered the problem when running a logstash container

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

Noticed that the shebang line (#!/bin/sh) on the entrypoint.sh was typed in the second line instead of the first line of the entrypoint.sh file.

When the shebang line is made as to the first line in the script, the error went away and "docker run -it logstashimage:latest sh" worked perfectly.



来源:https://stackoverflow.com/questions/58298774/standard-init-linux-go211-exec-user-process-caused-exec-format-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!