Reputation: 8480
Consider we have two different Docker images both exposing the same port (80, for example).
Now we'd like to create a multi-container Pod in Kubernetes cluster that contains containers created from these images.
Is there a way to setup such configuration without changing images? How to map ports on Pod level?
Upvotes: 2
Views: 2377
Reputation: 13739
Containers inside a Kubernetes Pod share different linux namespaces for things like networking, pid or file system. From the docs
Each Pod is assigned a unique IP address. Every container in a Pod shares the network namespace, including the IP address and network ports. Containers inside a Pod can communicate with one another using localhost
So the same way you can't have two processes listening on the same port on your machine, you can't have two containers that share the networking namespace listen on the same port.
Upvotes: 5