Port mapping:

When we run the below command, port 80 on the host is mapped to port 8080 on the container.


As a result, port 80 on the host could not be used by any other container

Let's now start another container and bind its port 8080 to port 8080 on the host:




Now, both ports, 80 and 8080 on the host are bound to our containers.

As the number of containers rises, we will face the issue of ports availability. 
Also keeping track of the available ports on the host will become hard to manage.

The solution - Pods - :

Pods are units in which we could run a handful of containers. 
Pods have their own IP addresses and live in their own network namespace.
They are connected to the network infrastructure through virtual Ethernet connections.
We can have applications tied to ports 8080 for example on different pods without having a conflict of ports.


Below is the Yaml representation of our pod:


The pod is a virtual host with its own IP address and a range of ports that could be assigned to its containers.
We don't need to worry about the port mapping on the host.

We could also run a second copy of the above container on the same port with no issues. 
Different pods have different IP addresses:


Brando Sabatini and Ikbal C ©. Powered by Blogger.