<p>In a Deployment of Kubernetes, what is the difference between <code>spec.containers.name</code> and <code>spec.hostname</code>?</p>
<pre><code>spec:
  containers:
    - env:
        - name: CONFIG_HOME
          value: /config
      image: my-image:1.0.0.0-SNAPSHOT
      name: name-a
      ports:
        - containerPort: 8080
      ...
  hostname: name-b
</code></pre>

<p><strong>Container name</strong></p>
<p>Container name it's just the <strong>name</strong> you are providing to identify it.</p>
<p>it is useful to debug the <strong>POD</strong> when <strong>failing</strong> or running <strong>multiple</strong> <strong>containers</strong> inside <strong>single</strong> <strong>POD</strong>.</p>
<p>Get logs of <strong>specific</strong> container</p>
<pre><code>kubectl logs &lt;pod-name&gt; -c &lt;container-name&gt;
</code></pre>
<p><strong>Hostname</strong></p>
<p>Only <strong>service</strong> get the <strong>DNS</strong> name record mapping not POD so you can't call the specific POD over <strong>DNS</strong> name unless you are using <strong>statefulset</strong>.</p>
<pre><code>hostname: busybox-2
subdomain: busybox-subdomain
</code></pre>
<p><strong>hostname</strong> and <strong>subdomain</strong> you can use the give <strong>DNS</strong> mapping to POD. FQDN fully qualified domain name.</p>
<p>You will be able to request that <strong>POD</strong> over the</p>
<pre><code>hostname.subdomain.namespace-name.svc.cluster.local
</code></pre>
<p>you can <strong>curl</strong> the <code>hostname.subdomain.namespace-name.svc.cluster.local</code></p>
