I am trying to attach to a running container in Kubernetes, however I get the error message below.
>kubectl attach -it es-client-2756725635-4rk43 -c es-node
Unable to use a TTY - container es-node did not allocate one
If you don't see a command prompt, try pressing enter.
How do I enable a TTY in my container yaml?
The reason why it's failiing is because you're not passing the bash argument. This causes a failure when trying to create a tty connection.
Please try:
kubectl exec -it [POD-NAME] -c [CONTAINER-NAME] bash
In order to have proper TTY and stdin when doing attach:
kubectl attach -it POD -c CONTAINER
The container must be configured with tty: true
and stdin: true
.
By default both of those values are false
: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#debugging
Example Pod:
spec:
containers:
- name: web
image: web:latest
tty: true
stdin: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With