无法在映像中执行linux命令



我使用minikube在mac中启动容器,并能够旋转容器,但我无法运行像ls这样的命令并得到错误(otel-collector-lzvwv是pod名称(:

kubectl exec --namespace="adalyu-k8s" --stdin --tty otel-collector-lzvwv -- ls
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ls": executable file not found in $PATH: unknown
command terminated with exit code 126

我怀疑图像有问题,但这是我第一次看到我可以运行程序,但无法运行像ls这样的命令,所以我想知道该怎么做才能使其可用。以下是包含图像的吊舱的描述:

➜  kubernetes git:(main) ✗ kubectl describe po -n adalyu-k8s otel-collector-lzvw
Name:         otel-collector-lzvwv
Namespace:    adalyu-k8s
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Tue, 16 Nov 2021 22:18:41 +0800
Labels:       app=opentelemetry
component=otel-collector
controller-revision-hash=6bbb66bc8d
pod-template-generation=1
Annotations:  <none>
Status:       Running
IP:           172.17.0.2
IPs:
IP:           172.17.0.2
Controlled By:  DaemonSet/otel-collector
Containers:
otel-collector:
Container ID:   docker://22a4aa11d6e7c3ea9b03434bab4de6aa69279ed2424e95183d7c36ef4fe05c90
Image:          otel/opentelemetry-collector-contrib:0.37.1
Image ID:       docker-pullable://otel/opentelemetry-collector-contrib@sha256:7193b50f65daf4a915ecdec928faa4c965a0f1b264f13aa37d516d0459569dac
Port:           <none>
Host Port:      <none>
State:          Running
Started:      Tue, 16 Nov 2021 22:18:43 +0800
Ready:          True
Restart Count:  0
Limits:
cpu:     100m
memory:  200Mi
Requests:
cpu:        100m
memory:     200Mi
Environment:  <none>
Mounts:
/etc/otel/config.yaml from data (ro,path="config.yaml")
/var/lib/docker/containers from varlibdockercontainers (ro)
/var/log from varlog (ro)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-dvr8p (ro)
Conditions:
Type              Status
Initialized       True
Ready             True
ContainersReady   True
PodScheduled      True

图像可能不支持bash,但也可以尝试使用-it第一个

kubectl exec-it-namespace=";adalyu-k8s"--stdin--tty otel收集器lzvvvv--/bin/bash或/bin/sh

并检查ls命令是否工作

我建议使用sh而不是bash进行检查

kubectl exec --namespace="adalyu-k8s" --stdin --tty otel-collector-lzvwv -- /bin/sh
/bin/sh

最新更新