【发布时间】:2020-10-19 14:32:04
【问题描述】:
我正在初始化容器中创建一个文件,并希望在主容器中使用该文件。
containers:
- name: test1
imagePullPolicy: Always
image: newbusybox
command:
- "some command --from-file=tmp/file.txt"
volumeMounts:
- name: workdir
mountPath: /tmp
initContainers:
- name: install
image: busybox
command: ["/bin/sh", "-c"]
args: ["echo test > /pod-data/file.txt]
volumeMounts:
- name: workdir
mountPath: /pod-data/
volumes:
- name: workdir
emptyDir: {}
Pods 进入 crashlookBack off 并出现以下错误
Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"some command --from-file=tmp/file.txt\": stat some comamnd --from-file=tmp/file.txt: no such file or directory": unknown
我已验证文件已安装在 tmp 位置。
【问题讨论】:
-
您可以尝试更改
command字段以使其像这样工作吗? kubernetes.io/docs/tasks/inject-data-application/…报错信息表明错误不在文件共享中,而是在命令规范中 -
我认为您只是在开头缺少一个正斜杠(
--from-file=/tmp/file.txt而不是--from-file=tmp/file.txt) -
好的,我也试过了。同样的问题--------------------------------------------- -------------------------------------------------- -------------------------------------- 图片:“ubuntu:14.04” 命令:- touch tmp 。文本 - - - - - - - - - - - - - - - - - - - - - - - - --------------- 错误:无法启动容器“my-container”:来自守护进程的错误响应:OCI 运行时创建失败:container_linux.go:349:启动容器进程导致“exec: \"touch tmp.txt\": $PATH 中找不到可执行文件":
-
请尝试在 initContainer ->
command: ["bin/sh"] args: ["-c", "echo hello > /pod-data/hello.txt"]中使用。在主容器中:command: [/bin/sh] args: ["-c","cat /tmp/hello.txt; sleep infinity"]
标签: kubernetes google-kubernetes-engine