Kubernetes部署失败。谁能告诉我哪里出了问题?
我的观察:当我删除卷挂载的东西,服务反弹
volumeMounts:
- name: my-volume
mountPath: /app
volumes:
- name: my-volume
hostPath:
path: /tmp/vpath
删除上面的代码
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: ContainerCannotRun
Message: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./main": stat ./main: no such file or directory: unknown
这是我的部署文件
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yml
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: stservice
name: stservice
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: stservice
strategy: {}
template:
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yml
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: stservice
spec:
containers:
- image: stservice
name: stservice
imagePullPolicy: Never
ports:
- containerPort: 5001
- containerPort: 5002
volumeMounts:
- name: my-volume
mountPath: /app
volumes:
- name: my-volume
hostPath:
path: /tmp/vpath
status: {}
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yml
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: stservice
name: stservice
spec:
ports:
- name: "5001"
port: 5001
targetPort: 5001
- name: "5002"
port: 5002
targetPort: 5002
selector:
io.kompose.service: stservice
status:
loadBalancer: {}
谁能告诉我为什么卷挂载会导致这个失败
Message: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./main": stat ./main: no such file or directory: unknown
我想你可能是在DockerfileWORKDIR上挂载卷,因此您正在覆盖它正在查找的文件并抛出此错误:"…/main: no such file or directory:".
如果是这个问题,更新docker的WORKDIR或挂载路径。如果这不是问题,请包含Dockerfile。