我正在构建用于python脚本的Dockerfile,它将在下面的minikube Windows 10系统中运行
使用以下命令构建docker
docker build -t python-helloworld .
并将其加载到minikube docker demon中
docker 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作业文件)
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
但是获得以下错误作业并不能成功运行,但是当您单独运行Dockerfile时,它的工作正常
standard_init_linux.go:211:exec用户进程导致“ exec格式错误”