<p>I having my Pod manifest as below:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: pod-nginx-container
spec:
  containers:
  - name: nginx-alpine-container-1
    image: nginx:alpine
    ports:
      - containerPort: 80
</code></pre>
<p>And I can get a shell to the Container running my Nginx using <code>kubectl exec --stdin --tty pod-nginx-container -- /bin/sh</code></p>
<p>My question is does Kubernetes always give a shell to the running container? I mean suppose I have created my own image of Tomcat webserver, and when I use that image then will I still get the shell to login to the container running Tomcat?</p>

pjj
<h2>Kubernetes</h2>
<p>Kubernetes schedules <a href="https://kubernetes.io/docs/concepts/workloads/pods/" rel="noreferrer">Pods</a> to nodes. A Pod consists of one or more containers - that are instantiated from container images.</p>
<h2>Container image</h2>
<p>A container image contains a command that will run as the main process but it can also contain other binaries and also a full Linux &quot;userland&quot; like e.g. Ubuntu with shell and lots of tools.</p>
<p>Container images <em>can</em> be built from &quot;scratch&quot; without any other software than e.g. your app, but typically contain some more software for your app to be runnable e.g. <code>glibc</code>. See <a href="https://github.com/GoogleContainerTools/distroless" rel="noreferrer">distroless</a> for minimal base images that does not contain a <em>shell</em>.</p>
<h2>Conclusion</h2>
<blockquote>
<p>My question is does Kubernetes always give a shell to the running container? I mean suppose I have created my own image of Tomcat webserver, and when I use that image then will I still get the shell to login to the container running Tomcat?</p>
</blockquote>
<p>Your container contain a shell, only if you have built in a shell - most likely by using a base image that contain a shell e.g. alpine or ubuntu.</p>
<p>It depends on what do you do in your <code>Dockerfile</code> before building a container image with <code>docker build</code></p>
