Kubernetes cronjob 没有文件或目录,但它在 docker 图像中

Kubernetes cronjob no file or directory but it's in the docker image

kubernetes cronjob 有问题,当它运行时它说 /usr/share/nginx/html 不是目录,“没有这样的文件或目录”,但它肯定是,它被烘焙到图像中,如果我将图像直接加载到 docker 文件夹肯定在那里。

这是 yaml:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: php-cron
spec:

  jobTemplate:
    spec:
      backoffLimit: 2
      activeDeadlineSeconds: 1800
      completions: 2
      parallelism: 2
      template:
        spec:
          containers:
            - name: php-cron-video
              image: my-image-here
              command:
                - "cd /usr/share/nginx/html"
                - "php bin/console processvideo"
              volumeMounts:
                - mountPath: /usr/share/nginx/html/uploads
                  name: uploads-volume
                - mountPath: /usr/share/nginx/html/private_uploads
                  name: private-uploads-volume
          restartPolicy: Never
          volumes:
            - name: uploads-volume
              hostPath:
                path: /data/website/uploads
                type: DirectoryOrCreate
            - name: private-uploads-volume
              hostPath:
                path: /data/website/private_uploads
                type: DirectoryOrCreate
  schedule:  "* * * * *"


docker run -it --rm my-image-here bash

直接加载到 /usr/share/nginx/html 文件夹

这是怎么回事?相同的图像和正常部署一样工作正常。

假设您的图片确实 /usr/share/nginx/html/bin 已经融入,请尝试将 command 更改为:

...
command: ["sh","-c","cd /usr/share/nginx/html && php bin/console processvideo"]
...