<p>I have a legacy <code>Deployment.yaml</code> that is used by Helm and works fine so far.</p>

<pre><code>      containers:
        ports:
          - containerPort: 3000
</code></pre>

<p>This part here was wrongly indended before. So the <code>ports</code> part of it wasn't active or used in k8s as far as I understand.</p>

<p>So what wonders me now is how the container was running and accessible at port 3000 the whole time? So I looked for another definition describing this port.</p>

<p>I found it in the <code>Dockerfile</code></p>

<pre><code>   EXPOSE 3000
</code></pre>

<p>My question is now - do you need to define <code>port.containerPort</code> in the .yaml configuration or is the container port already implied to be at 3000 through the <code>Dockerfile</code>'s <strong>EXPOSE</strong> statement?</p>

<p>It feels like k8s knows that this should be the containerport since the Dockerfile describes it.</p>

<p>NO, <code>EXPOSE</code> hat nothing to do with this, that only an Info for you that the container will use <code>port 3000</code>. the configuration is coming from <code>containerPort</code></p>

<p>for <code>k8s</code> see <a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/" rel="nofollow noreferrer">this</a></p>

<p>for <code>expose</code> see <a href="https://docs.docker.com/engine/reference/builder/#expose" rel="nofollow noreferrer">this</a></p>
