Search code examples
dockerkubernetescontainers

Why I get exec failed: container_linux.go:380 when I go inside Kubernetes pod?


I started learning about Kubernetes and I installed minikube and kubectl on Windows 7.

After that I created a pod with command:

kubectl run firstpod --image=nginx

And everything is fine:

[![enter image description here][1]][1]

Now I want to go inside the pod with this command: kubectl exec -it firstpod -- /bin/bash but it's not working and I have this error:

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

How can I resolve this problem?

And another question is about this firstpod pod. With this command kubectl describe pod firstpod I can see information about the 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

So I can see it is a docker container id and it is started, also there is the image, but if I do docker images or docker ps there is nothing. Where are these images and container? Thank you! [1]: https://i.sstatic.net/xAcMP.jpg


Solution

  • One error for certain is gitbash adding Windows the path. You can disable that with a double slash:

    kubectl exec -it firstpod -- //bin/bash
    

    This command will only work if you have bash in the image. If you don't, you'll need to pick a different command to run, e.g. /bin/sh. Some images are distroless or based on scratch to explicitly not include things like shells, which will prevent you from running commands like this (intentionally, for security).