Multi container pod query

Hello,

in CKA course, in POD video it states that "if we have 2 containers in same POD, they both can communicate to each other directly by reffering to each other as ‘localhost’ as they share the same network namespace. "

So does that mean if do a ping localhost from one container, will it ping to to another container? As normally localhost refers to itself.

Thanks
Ashish

That does not make sense if you ping localhost and receive the answer from another container.

Hi @06ashishrawat,

The 2 containers can communicate to each other through localhost so that means If the first container service works on port 3000 and the second container works on port 4000, The first one can reach the second through localhost:4000, The second one can reach the first through localhost:3000.

exactly @Nasri that’s why I was confused. How’s that possible, but now after the reply from @KodeKloud now it’s clear. If the first container service works on port 3000 and the second container works on port 4000, The first one can reach the second through localhost:4000 , The second one can reach the first through localhost:3000 .

Thanks @KodeKloud for your clarification. Now it’s clear.