Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 为什么我的Debian容器意外终止_Kubernetes_Google Kubernetes Engine - Fatal编程技术网

Kubernetes 为什么我的Debian容器意外终止

Kubernetes 为什么我的Debian容器意外终止,kubernetes,google-kubernetes-engine,Kubernetes,Google Kubernetes Engine,我刚接触Docker容器,仍处于学习阶段。我试图在我的Kubernetes免费帐户中测试以下代码 apiVersion: v1 kind: Pod metadata: name: two-containers spec: restartPolicy: Never volumes: - name: shared-data emptyDir: {} containers: - name: nginx-container image: nginx vol

我刚接触Docker容器,仍处于学习阶段。我试图在我的Kubernetes免费帐户中测试以下代码

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:
  restartPolicy: Never
  volumes:
  - name: shared-data
    emptyDir: {}
  containers:
  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html
  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]
这部分工作正常

但是,当我运行Debian容器时,它在将
/pod data/index.html
写入共享卷路径后立即终止,我无法理解为什么会发生这种情况


以前是否有人遇到过这种情况,谁有可能找到解决方案。

因为它执行指定的命令,然后完成。脚本完成了,并没有更多的事情要做,所以pod被终止。POD和Docker容器应该是长时间运行的进程。如果您需要运行运行并完成的脚本,则应该考虑使用.

,因为它执行指定的命令,然后完成。脚本完成了,并没有更多的事情要做,所以pod被终止。POD和Docker容器应该是长时间运行的进程。如果需要运行运行并完成的脚本,则应该考虑使用.< /P> 如果查看debian容器,您会看到它正在将“Hello from the debian container”写入/pod data/index.html

这个过程已经完成,没有更多的事情要做。因此,容器被终止

另一方面,nginx容器运行一个守护进程,该进程一直在运行,为最终用户提供web内容,因此它将继续运行

如果查看debian容器,您会看到它正在将“Hello from the debian container”写入/pod data/index.html

这个过程已经完成,没有更多的事情要做。因此,容器被终止


另一方面,nginx容器运行一个守护进程,该进程一直在运行,为最终用户提供web内容,因此它将继续运行。

如何接受,抱歉,我不知道。我也是新来的!这里会看到这个答案上有一个记号图标。你需要点击如何接受,对不起,我不知道。我也是新来的!这里会看到这个答案上有一个记号图标。你需要点击那个
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]