How does port publishing from a docker container to a kubernetes pod work? How does port publishing from a docker container to a kubernetes pod work? kubernetes kubernetes

How does port publishing from a docker container to a kubernetes pod work?


Containers running in a pod are similar to processes running on a node connected to a network. Pod gets has a network address, and all containers share the same network address. They can talk to each other using localhost.

A container running in a pod can listen to any port on that address. If there are multiple containers running in a pod, they cannot bind to the same port, only one of them can. Note that there is no requirement about publishing those ports. A container can listen to any port, and traffic will be delivered to it if a client connects to that port of the pod.

So, port mapping from container to pod is not possible.

The exposed ports of containers/pods are mainly informational, and tools use them to create resources.