I want to run a shell command to execute to the following container, the problem is that when I run exec I got error, how can I exec to distroless container
this is the deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: distro
labels:
app: distro
spec:
replicas: 1
selector:
matchLabels:
app: distro
template:
metadata:
labels:
app: distro
spec:
containers:
- name: edistro
image: timberio/vector:0.21.X-distroless-libc
ports:
- containerPort: 80
what I tried is kubectl exec -i -t -n apits aor-agent-zz -c tor "--" sh -c "clear; (bash || ash || sh)"
The error is: error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec
CodePudding user response:
The point of using distro-less
is to have a minimal amount of tools/software packaged in the image. This means the removal of unnecessary tools like shell
from the image.
You may work around using, however it may depend on your objective:
kubectl debug -it <POD_TO_DEBUG> --image=<helper-image> --target=<CONTAINER_TO_DEBUG> --share-processes
enter code here
Eg:
kubectl debug -it distro-less-pod --image=ubuntu --target=edistro --share-processes
CodePudding user response:
You can't exec into a distroless container. You can try kubectl debug to start an ephemeral container running side-by-side with the target container to start a shell session.