本文介绍了standard_init_linux.go:211:exec用户进程引起"exec格式错误".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建用于python脚本的Dockerfile,它将在下面的minikube Windows 10系统中运行

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

使用以下命令构建dockerdocker build -t python-helloworld .

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

并将其加载到minikube docker恶魔中docker save python-helloworld | (eval $(minikube docker-env) && docker load)

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

Docker文件

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文件(cron作业文件)

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

以下是运行此Kubernetes作业的命令kubectl create -f pythoncronjob.yml

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

但是无法成功运行以下错误作业,但是当您独自运行Dockerfile时,它的工作正常

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用户进程导致"exec格式错误"

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

推荐答案

我看到您将命令command: [/app/helloworld.py]添加到yaml文件中.

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

所以您需要(在Dockerfile中):

so you need to (in Dockerfile):

RUN chmod +x /app/helloworld.py

将shebang设置为您的py文件:

set shebang to your py file:

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

或设置与Dockerfile

这篇关于standard_init_linux.go:211:exec用户进程引起"exec格式错误".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 21:59