Score:0

Why can I not attach a shell to Google's hello-app:v1 container?

ai flag

I've deployed a simple Kubernetes bare pod (hello-world-pod) in a cluster with nodes running Ubuntu 18.04 in Vagrant. When I run this command,

kubectl exec -it hello-world-pod -- /bin/sh

...I get the error:

error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "0cc4cd8766f1e809ede55707dd422ffa4509804beb2006200b05ff4197f9a63c": OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory: unknown

Why can I not attach a shell to the container in this pod? I am able to successfully attach a shell to the ubuntu container and the nginx container, but not this one.

Here is the manifest for the problematic pod:

apiVersion: v1
kind: Pod
metadata:
  name: hello-world-pod
spec:
  containers:
  - name: hello-world
    image: gcr.io/google-samples/hello-app:1.0
    ports:
    - containerPort: 80

BTW I'm using containerd, not docker, as my runtime environment.

Thanks in advance!

Score:0
uy flag

Welcome, this sample container is a pretty small container with 26.8 MB. A shell is not needed, so the maintainer did not install a shell. See Error message /bin/sh: no such file or directory

Container should be kept as small as possible, things that are not needed should not be installed. The runtime environment does not matter.

wwillfred avatar
ai flag
That makes sense, but in the Pluralsight course [Managing the Kubernetes API Server and Pods](https://www.pluralsight.com/courses/managing-kubernetes-api-server-pods), the instructor attaches a shell to this container and in a different example executes the `/usr/bin/killall` command on this container. Did this container use to have a shell and other commands that are no longer there in the current version?
dummyuser avatar
uy flag
I cannot comment in content of Pluralsight as I do not know details of the training. Even `/usr/bin/killall` is not installed in this container, but I never needed a `/usr/bin/killall` inside a container.
Score:0
nc flag

Apparently the shell is gone in the later revisions.

Try using an older version of the image for the Pluralsight demo, e.g. gcr.io/google-samples/hello-app@sha256:2b0febe1b9bd01739999853380b1a939e8102fd0dc5e2ff1fc6892c4557d52b9

It even has killall.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.