<p>I am creating a long-lived jump to run inside of my kubernetes cluster. It uses an EBS volume for the home folder, holds important copies of my code, and gives me fast access for routine behavior. The problem is that I can't use GNU <code>screen</code> to create similarly long-lived sessions.</p>

<p>Here's my Dockerfile:</p>

<pre><code>FROM ubuntu:zesty

ENV KUBECTL_VERSION=v1.7.6

RUN apt-get update &amp;&amp; \
    apt-get install -y \
      htop vim sysstat \
      build-essential make \
      ruby ruby-dev rake \
      postgresql-client libpq-dev \
      curl wget \
      python python-pip &amp;&amp; \
    pip install awscli &amp;&amp; \
    gem install --no-rdoc --no-ri bundler
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl &amp;&amp; \
    chmod a+x kubectl &amp;&amp; \
    mv kubectl /usr/local/bin/kubectl
ADD dotfiles /root-dotfiles
ADD code /root-code
ADD docker-entrypoint.sh /docker-entrypoint.sh
</code></pre>

<p>And here's how I deploy it:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: doit
    purpse: jumpbox
  name: doit
  namespace: default
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: doit
      purpose: jumpbox
  template:
    metadata:
      labels:
        app: doit
        purpose: jumpbox
    spec:
      containers:
      - image: 123.dkr.ecr.eu-central-1.amazonaws.com/doit:latest
        imagePullPolicy: Always
        name: doit
        command: ["sleep", "infinity"]
        workingDir: /root
        env:
        - name: TERM
          value: xterm
        volumeMounts:
        - mountPath: /root
          subPath: root-homedir
          name: doit-home
      volumes:
        - name: doit-home
          persistentVolumeClaim:
            claimName: doit-home
      restartPolicy: Always
      securityContext: {}
      terminationGracePeriodSeconds: 1
</code></pre>

<p>But when I <code>kubectl exec</code> in to the container and try creating a screen:</p>

<pre><code>root@doit-2561276907-kl2h6:~# screen -S asdf
Cannot open your terminal '' - please check.
</code></pre>

<p>I can work around this by doing:</p>

<pre><code>root@doit-2561276907-kl2h6:~# script /dev/null
Script started, file is /dev/null
# bash
root@doit-2561276907-kl2h6:~# screen -S asdf
# now inside of the screen
</code></pre>

<p>Also, here's how I connect to the Pod:</p>

<pre><code>function doit {
  doit_pods=$(kubectl get pods -l 'app==doit'  -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
  kubectl exec -it $doit_pods bash
}
</code></pre>

<p>So under the hood I am doing <code>kubectl exec -it</code>.</p>

<p>But I don't want all the users of this jumpbox instance to have to run script and switch back to bash. How can I create Pod which is already configured properly for <code>screen</code>?</p>

<p>I tried this with centos image  it works, need to check the ubuntu image.</p>

<pre><code>kubectl run -it screentest --image=centos -- bash
kubectl exec -it screentest-cbd49447f-286wq -- bash
yum -y install screen
screen
</code></pre>

<p>Tested this in ubuntu also, it works for me.</p>

<pre><code>kubectl run -it ubuntuest --image=ubuntu -- bash
apt-get update -qq &amp;&amp; apt-get install screen -y
screen
</code></pre>

<p>also tried with <code>kubectl exec -it ubuntuest-78df75fbb-9sk6f -- bash</code> it works.</p>
