kubectl attach: Unable to use a TTY - container es-node did not allocate one

speedplane picture speedplane · Oct 6, 2016 · Viewed 13.8k times · Source

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?

Answer

Alex Plugaru picture Alex Plugaru · Feb 2, 2017

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/api-reference/v1.5/#container-v1

Example Pod:

spec:
      containers:
      - name: web
        image: web:latest
        tty: true
        stdin: true