我開始學習 Kubernetes,并在 Windows 7 上安裝了 minikube 和 kubectl。
之后,我使用命令創建了一個 pod:
kubectl run firstpod --image=nginx
一切都很好:
[![在此處輸入影像描述][1]][1]
現在我想用這個命令進入 pod:kubectl exec -it firstpod -- /bin/bash但它不起作用,我有這個錯誤:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container
process caused: exec: "C:/Program Files/Git/usr/bin/bash.exe": stat C:/Program
Files/Git/usr/bin/bash.exe: no such file or directory: unknown
command terminated with exit code 126
我該如何解決這個問題?
另一個問題是關于這個firstpod吊艙的。使用此命令,kubectl describe pod firstpod我可以查看有關 pod 的資訊:
Name: firstpod
Namespace: default
Priority: 0
Node: minikube/192.168.99.100
Start Time: Mon, 08 Nov 2021 16:39:07 0200
Labels: run=firstpod
Annotations: <none>
Status: Running
IP: 172.17.0.3
IPs:
IP: 172.17.0.3
Containers:
firstpod:
Container ID: docker://59f89dad2ddd6b93ac4aceb2cc0c9082f4ca42620962e4e692e3d6bcb47d4a9e
Image: nginx
Image ID: docker-pullable://nginx@sha256:644a70516a26004c97d0d85c7fe1d0c3a67ea8ab7ddf4aff193d9f301670cf36
Port: <none>
Host Port: <none>
State: Running
Started: Mon, 08 Nov 2021 16:39:14 0200
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-9b8mx (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-9b8mx:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 32m default-scheduler Successfully assigned default/firstpod to minikube
Normal Pulling 32m kubelet Pulling image "nginx"
Normal Pulled 32m kubelet Successfully pulled image "nginx" in 3.677130128s
Normal Created 31m kubelet Created container firstpod
Normal Started 31m kubelet Started container firstpod
所以我可以看到它是一個 docker 容器 id 并且它已經啟動,還有影像,但是如果我這樣做了docker images或者docker ps什么都沒有。這些影像和容器在哪里?謝謝![1]:https : //i.stack.imgur.com/xAcMP.jpg
uj5u.com熱心網友回復:
一個錯誤是 gitbash 添加 Windows 路徑。您可以使用雙斜線禁用它:
kubectl exec -it firstpod -- //bin/bash
此命令僅在映像中有 bash 時才有效。如果不這樣做,則需要選擇一個不同的命令來運行,例如/bin/sh. 有些鏡像是無發行版的或基于scratch 的,以明確不包含shell 之類的東西,這將阻止您運行這樣的命令(出于安全考慮,這是故意的)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/354123.html
標籤:码头工人 Kubernetes 集装箱
