title: what is the relationship between EXPOSE in the dockerfile and TARGETPORT in the service YAML and actual running port in the Pod?
body: <p>What is the relationship between EXPOSE in the dockerfile and TARGETPORT in the service YAML and actual running port in the Pod ?</p>
  
  <p>In my dockerfile</p>
  
  <pre><code>expose 8080
  </code></pre>
  
  <p>in my deployment</p>
  
  <pre><code>ports:
    - containerPort: 8080
  </code></pre>
  
  <p>In my service</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
   name: xtys-web-admin
  spec:
   type: NodePort
   ports:
    - port: 8080
      targetPort: 8080
   selector:
    app: xtys-web-admin
  </code></pre>
  
  <p>In my pod</p>
  
  <pre><code>kubectl exec xtys-web-admin-7b79647c8d-n6rhk -- ss -tnl
  State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port 
  LISTEN     0      100                       *:8332                     *:*     
  </code></pre>
  
  <p>So, in the pod actually running 8332( from some config file).
  my question is how does it still works ? it works,but i doubt it, someone can clarify it?</p>