<p>Using Ubuntu 19.10 using standard GNOME terminal.</p>

<p>I have build a docker image with <a href="https://github.com/nvm-sh/nvm" rel="nofollow noreferrer">nvm</a> using the following dockerfile (its going to be a npm diagnostic/debug command line container so not application):</p>

<pre><code>FROM ubuntu:19.10

RUN rm /bin/sh &amp;&amp; ln -s /bin/bash /bin/sh

RUN apt-get update &amp;&amp; \
    apt-get -y dist-upgrade &amp;&amp; \
    apt-get -y autoremove &amp;&amp; \
    apt-get clean

RUN apt-get install -y \
    curl \
    nano \
    git 

ARG NODE_VERSION='12.0.0'
ARG NVM_DIR=/root
ARG NVM_VERSION='v0.35.3'

RUN curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh" | bash \
    &amp;&amp; source $NVM_DIR/nvm.sh \
    &amp;&amp; nvm install $NODE_VERSION
</code></pre>

<p>I have build an image and pushed it to an image registry and started it in k8s. I have the accessed the running container with:</p>

<pre><code>kubectl exec my-app-xx25 -it bash
</code></pre>

<p>But when inside the container I cannot start e.g. <code>nano</code>:</p>

<pre><code>root@my-app-xx25:/# nano
Error opening terminal: unknown.
</code></pre>

<p>or reset the terminal for that sake:</p>

<pre><code>root@my-app-xx25:/# reset
reset: unknown terminal type unknown
</code></pre>

<p><code>vi</code>/<code>vim</code> works though.</p>

<p>Based on:</p>

<p><a href="https://github.com/moby/moby/issues/9299" rel="nofollow noreferrer">https://github.com/moby/moby/issues/9299</a></p>

<p>If I do:</p>

<pre><code>kubectl exec my-app-xx25 -it -- bash -c "export TERM=xterm &amp;&amp; bash"
</code></pre>

<p>I can start nano just fine but seems like a messy workaround.</p>

<p>Notice if I run it locally with docker it works fine (starting nano, reset etc):</p>

<pre><code>docker run -it my-image /bin/bash
</code></pre>

<p>Any suggestions to what goes on and why I need to pass <code>export TERM=xterm</code> when running <code>kubectl exec</code> and not when running <code>docker run</code> (locally)?</p>

<p>It's kind of odd that you are running nano inside a Kubernetes pod/container. Given that your <code>kubectl exec ...</code> is not a root login shell, a workaround is to put the value in your <code>/root/.bashrc</code>:</p>

<p>export TERM=xterm</p>

<p>I'd recommend you build the container with the file built-in if you are going to run this on a regular basis because if it's not then every time your pod/container restart you will have to manually modify the <code>/.bashrd</code> content.</p>
