I read all I could find, but documentation on this scenario is scant or unclear for podman
. I have the following (contrived) ROOTLESS
podman
setup:
pod-1 name:
pod1
Container names in
pod1
:p1c1
-- This is also it's assignedhostname
withinpod1
p1c2
-- This is also it's assignedhostname
withinpod1
p1c3
-- This is also it's assignedhostname
withinpod1
pod-2 name:
pod2
Container names in
pod2
:p2c1
-- This is also it's assignedhostname
withinpod2
p2c2
-- This is also it's assignedhostname
withinpod2
p2c3
-- This is also it's assignedhostname
withinpod2
I keep certain containers in different pods
specifically to avoid port conflict
, and to manage containers as groups.
QUESTION:
Give the above topology, how do I communicate between, say, p1c1
and p2c1
? In other words, step-by-step, what podman(1)
commands do I issue to collect the necessary addressing information
for pod1:p1c1
and pod2:p2c1
, and then use that information to configure applications in them so they can communicate with one another?
Thank you in advance!
EDIT: For searchers, additional information can be found here.
Podman doesn't have anything like the "services" concept in Swarm or Kubernetes to provide for service discovery between pods. Your options boil down to:
For the first solution, we'd start by creating a network:
And then creating both pods attached to the
shared
network:With both pods running on the same network, containers can refer to the other pod by name. E.g, if you were running a web service in
p1c1
on port 80, inp2c1
you couldcurl http://pod1
.For the second option, you would do something like:
Now if
p1c1
has a service listening on port1234
, you can access that fromp2c1
at<some_host_address>:1234
.That's correct. Each pod runs with its own network namespace (effectively, it's own ip address), so services in different pods can listen on the same port.
In general you cannot change the configuration of a pod or a container; you can only delete it and create a new one. Assuming that
podman-compose
has relatively complete support for thedocker-compose.yaml
format, you should be able to set up the network correctly in yourdocker-compose.yaml
file (you would create the network manually, and then reference it as anexternal
network in your compose file).Here is a link to the relevant Docker documentation. I haven't tried this myself with podman.