elv*_*vis 3 containers docker kubernetes
我开始学习 Kubernetes,并在 Windows 7 上安装了 minikube 和 kubectl。
之后我使用命令创建了一个 pod:
kubectl run firstpod --image=nginx
Run Code Online (Sandbox Code Playgroud)
一切都很好:
[![在此处输入图像描述][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
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
另一个问题是关于这个firstpodPod 的。使用此命令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
Run Code Online (Sandbox Code Playgroud)
所以我可以看到它是一个 docker 容器 id 并且它已启动,也有图像,但如果我这样做docker images或docker ps什么也没有。这些图像和容器在哪里?谢谢你![1]: https: //i.stack.imgur.com/xAcMP.jpg
一个肯定的错误是 gitbash 添加 Windows 路径。您可以使用双斜杠禁用它:
kubectl exec -it firstpod -- //bin/bash
Run Code Online (Sandbox Code Playgroud)
仅当映像中有 bash 时,此命令才有效。如果不这样做,您将需要选择一个不同的命令来运行,例如/bin/sh。有些镜像是无发行版的或基于暂存的,明确不包含 shell 之类的东西,这将阻止您运行这样的命令(为了安全起见,是故意的)。