gpt4 book ai didi

docker - Pod因错误和退出代码原因而终止:1

转载 作者:行者123 更新时间:2023-12-02 20:33:21 30 4
gpt4 key购买 nike

我对使用图像的 pods 终止有疑问:kodekloud / throw-dice

pod-defintion.yml

apiVersion: v1
kind: Pod
metadata:
name: throw-dice-pod
spec:
containers:
- image: kodekloud/throw-dice
name: throw-dice
restartPolicy: Never

我已经检查了 DockerFile 中的步骤。它运行 throw-dice.sh,随机返回1到6之间的数字。

让我们考虑第一次容器返回3,那么下面的pod如何终止?如果脚本返回号为!6,则应该终止在pod级别中定义的条件在哪里。

执行以下步骤来执行pod-definition.yml
master $ kubectl create -f /root/throw-dice-pod.yaml
pod/throw-dice-pod created
master $ kubectl get pods
NAME READY STATUS RESTARTS AGE
throw-dice-pod 0/1 ContainerCreating 0 9s
master $ kubectl get pods
NAME READY STATUS RESTARTS AGE
throw-dice-pod 0/1 Error 0 12s
master $ kubectl describe pod throw-dice-pod
Name: throw-dice-pod
Namespace: default
Priority: 0
Node: node01/172.17.0.83
Start Time: Sat, 16 May 2020 11:20:01 +0000
Labels: <none>
Annotations: <none>
Status: Failed
IP: 10.88.0.4
IPs:
IP: 10.88.0.4
Containers:
throw-dice:
Container ID: docker://4560c794b58cf8f3e3fad691b2292e37db4e84e20c9286321f026d1735272b5f
Image: kodekloud/throw-dice
Image ID: docker-pullable://kodekloud/throw-dice@sha256:9c70a0f907b99293885a9591b6162e9ec89e127937626a97ca7f9f6be2d98b01
Port: <none>
Host Port: <none>
State: Terminated
Reason: Error
Exit Code: 1
Started: Sat, 16 May 2020 11:20:10 +0000
Finished: Sat, 16 May 2020 11:20:10 +0000
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-nr5kl (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-nr5kl:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-nr5kl
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned default/throw-dice-pod to node01
Normal Pulling 21s kubelet, node01 Pulling image "kodekloud/throw-dice"
Normal Pulled 19s kubelet, node01 Successfully pulled image "kodekloud/throw-dice"
Normal Created 19s kubelet, node01 Created container throw-dice
Normal Started 18s kubelet, node01 Started container throw-dice


master $ kubectl logs throw-dice-pod
2

最佳答案

dockerfile具有ENTRYPOINT sh throw-dice.sh,这意味着执行脚本,然后容器自动终止。如果您希望容器继续运行,则需要启动一个长时间运行的进程,例如,一个Java进程ENTRYPOINT ["java", "-jar", "/whatever/your.jar"]

关于docker - Pod因错误和退出代码原因而终止:1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61836061/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com