I have the following yml...
apiVersion: v1
kind: Pod
metadata:
name: simple-server
labels:
run: simple-server
spec:
containers:
- name: web
image: nginx
ports:
- name: web
containerPort: 80
protocol: TCP
Once applied I can access a bash shell like sudo kubectl exec --stdin --tty simple-server -- /bin/bash
. I have a simple Koa docker image I created from node:17-alpine
like this...
FROM node:17-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
EXPOSE 8080
CMD node server.mjs
apiVersion: v1
kind: Pod
metadata:
name: simple-server-node
labels:
run: simple-server-node
spec:
containers:
- name: web
image: partyk1d24/node-k8s-demo
ports:
- name: web
containerPort: 8080
protocol: TCP
This one deploys and I can access it using a service. However, when I try to open a tty bash shell I get...
node % sudo kubectl exec --stdin --tty pod/simple-server-node -- /bin/bash OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown command terminated with exit code 126
Why can't I open a shell in the node image the same way I can in the nginx one?
CodePudding user response:
Posting as answer for better visibility.
"Why can't I open a shell in the node image the same way I can in the nginx one?" - Because alpine does not come with bash installed. We can, however, use /bin/sh instead of /bin/bash.