This seems like a pretty basic use case but I cannot seem to find out how to do this: I want to create two containers, foo and bar, and have them talk to each other on ports that are not exposed to anything else. I used to do this by creating a docker network, my_network, that I attached my two containers to, and then I could access foo.my_network from the bar container. But how moving to RHEL 8 I have to port my code away from Docker and I can't figure out how to get my two containers to talk. It works fine on IP (10.88.0.10 and 10.88.0.11) but I would prefer to use the name since I don't trust the IP to be the same at every run. Any ideas?
On Wed, 2019-06-26 at 20:45 +0800, Christoffer Reijer wrote:
This seems like a pretty basic use case but I cannot seem to find out how to do this:
I want to create two containers, foo and bar, and have them talk to each other on ports that are not exposed to anything else. I used to do this by creating a docker network, my_network, that I attached my two containers to, and then I could access foo.my_network from the bar container. But how moving to RHEL 8 I have to port my code away from Docker and I can't figure out how to get my two containers to talk. It works fine on IP (10.88.0.10 and 10.88.0.11) but I would prefer to use the name since I don't trust the IP to be the same at every run.
Any ideas? _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
The quickest idea I would be to throw both containers in a pod. That way, they are in the same network namespace and can talk to each other over localhost. No need to expose ports and the IP addresses are irrelevant.
On 06/26/2019 10:36 AM, Brent Baude wrote:
On Wed, 2019-06-26 at 20:45 +0800, Christoffer Reijer wrote:
This seems like a pretty basic use case but I cannot seem to find out how to do this:
I want to create two containers, foo and bar, and have them talk to each other on ports that are not exposed to anything else. I used to do this by creating a docker network, my_network, that I attached my two containers to, and then I could access foo.my_network from the bar container. But how moving to RHEL 8 I have to port my code away from Docker and I can't figure out how to get my two containers to talk. It works fine on IP (10.88.0.10 and 10.88.0.11) but I would prefer to use the name since I don't trust the IP to be the same at every run.
Any ideas? _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io The quickest idea I would be to throw both containers in a pod. That way, they are in the same network namespace and can talk to each other over localhost. No need to expose ports and the IP addresses are irrelevant.
Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
Sounds like a great mini-demo/blog topic for podman.io.... t
Ok, thanks. I'll see if I can figure out how to do this. I currently manage my two containers using systemd services so I guess I need to create a third service for the pod and create some sort of dependency between the three services.
Hi, You can use podman-compose to do this, the same way you did with docker-compose. Just take care of volumes (these should be relative to somewhere you have access...). Best regards, Rémy. Le jeu. 27 juin 2019 à 19:46, Christoffer Reijer <ephracis@gmail.com> a écrit :
Ok, thanks. I'll see if I can figure out how to do this. I currently manage my two containers using systemd services so I guess I need to create a third service for the pod and create some sort of dependency between the three services. _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
On Thu, 27 Jun 2019, Rémy Dernat wrote:
Hi,
You can use podman-compose to do this, the same way you did with docker-compose. Just take care of volumes (these should be relative to somewhere you have access...).
is there a fedora package that provides podman-compose, i don't immediately see one. rday -- ======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ========================================================================
No, it is just a python script on github: https://github.com/muayyad-alsadi/podman-compose Le jeu. 27 juin 2019 à 20:47, Robert P. J. Day <rpjday@crashcourse.ca> a écrit :
On Thu, 27 Jun 2019, Rémy Dernat wrote:
Hi,
You can use podman-compose to do this, the same way you did with docker-compose. Just take care of volumes (these should be relative to somewhere you have access...).
is there a fedora package that provides podman-compose, i don't immediately see one.
rday
--
======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca
Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ========================================================================
I have created a pod and placed the containers inside it using --pod but I still cannot resolve the name of the container.
I also tried to access it on localhost which is how a pod works on kubernetes. But I don't run Kubernetes on this host so I'm not entirely sure how the "pod" philosophy works in this case when using podman. I just want to create 2 containers on the same host using podman and having container A access a service on container B. Please help me, I do not want to resort to installing docker on RHEL 8 just because of something as trivial as this. :(
Hey Christoffer, Pods were created for the use case you have in mind. By default, they should share a net namespace and be able to speak over localhost. What is the output of: ``` podman run -d --pod new:mypod nginx podman run --pod mypod fedora-minimal curl localhost:80 ``` This should successfully curl the nginx's default html. If it fails, there's something else going on here... Thanks, Peter On Fri, Jun 28, 2019 at 1:23 PM Christoffer Reijer <ephracis@gmail.com> wrote:
I also tried to access it on localhost which is how a pod works on kubernetes. But I don't run Kubernetes on this host so I'm not entirely sure how the "pod" philosophy works in this case when using podman.
I just want to create 2 containers on the same host using podman and having container A access a service on container B. Please help me, I do not want to resort to installing docker on RHEL 8 just because of something as trivial as this. :( _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
That example worked. It turns out I forgot to start the pod. :) Anyway, I'm still having some issues since I want to use systemd to manage my containerized services on the host. My current strategy is to use a single service to manage the pod including the containers. I have the following service file: [Unit] Description=Test Wants=syslog.service [Service] Restart=always ExecStartPre=-/usr/bin/podman stop containerA containerB ExecStartPre=-/usr/bin/podman pod stop test ExecStartPre=-/usr/bin/podman rm containerA containerB ExecStartPre=-/usr/bin/podman pod rm test ExecStartPre=/usr/bin/podman pod create --name test ExecStartPre=/usr/bin/podman create --pod test --name containerA imageA ExecStartPre=/usr/bin/podman create --pod test --name containerB imageB ExecStart=/usr/bin/podman start test ExecStop=/usr/bin/podman stop test [Install] WantedBy=multi-user.target It works when I fire off the commands manually, but when I try to start the service it becomes dead and the pod gets status Exited, killing the two containers inside it. Again, when I run all the commands from the shell manually the pod comes up fine and runs without problems. Ideas?
Hi, Hum, maybe you could try to change the ExecLine with "podman run -d ..." Instead of "podman start ..." ?? By the way, one advantage of podman is that it is daemonless + rootless. IMHO, you will loose one advantage, except if you put your systemd file in a user define space (eg: /etc/systemd/system/user@.podman.service) Best regards, Rémy. Le sam. 29 juin 2019 à 20:58, Christoffer Reijer <ephracis@gmail.com> a écrit :
That example worked. It turns out I forgot to start the pod. :)
Anyway, I'm still having some issues since I want to use systemd to manage my containerized services on the host. My current strategy is to use a single service to manage the pod including the containers. I have the following service file:
[Unit] Description=Test Wants=syslog.service [Service] Restart=always ExecStartPre=-/usr/bin/podman stop containerA containerB ExecStartPre=-/usr/bin/podman pod stop test ExecStartPre=-/usr/bin/podman rm containerA containerB ExecStartPre=-/usr/bin/podman pod rm test ExecStartPre=/usr/bin/podman pod create --name test ExecStartPre=/usr/bin/podman create --pod test --name containerA imageA ExecStartPre=/usr/bin/podman create --pod test --name containerB imageB ExecStart=/usr/bin/podman start test ExecStop=/usr/bin/podman stop test [Install] WantedBy=multi-user.target
It works when I fire off the commands manually, but when I try to start the service it becomes dead and the pod gets status Exited, killing the two containers inside it.
Again, when I run all the commands from the shell manually the pod comes up fine and runs without problems. Ideas? _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
Maybe you should also check your namespaces and pods when launching your containers in the ExecStart line (lsns && ...). I think that Systemd is using its own namespaces... Le sam. 29 juin 2019 à 21:24, Rémy Dernat <remy.d1@gmail.com> a écrit :
Hi,
Hum, maybe you could try to change the ExecLine with "podman run -d ..." Instead of "podman start ..." ??
By the way, one advantage of podman is that it is daemonless + rootless. IMHO, you will loose one advantage, except if you put your systemd file in a user define space (eg: /etc/systemd/system/user@.podman.service)
Best regards, Rémy.
Le sam. 29 juin 2019 à 20:58, Christoffer Reijer <ephracis@gmail.com> a écrit :
That example worked. It turns out I forgot to start the pod. :)
Anyway, I'm still having some issues since I want to use systemd to manage my containerized services on the host. My current strategy is to use a single service to manage the pod including the containers. I have the following service file:
[Unit] Description=Test Wants=syslog.service [Service] Restart=always ExecStartPre=-/usr/bin/podman stop containerA containerB ExecStartPre=-/usr/bin/podman pod stop test ExecStartPre=-/usr/bin/podman rm containerA containerB ExecStartPre=-/usr/bin/podman pod rm test ExecStartPre=/usr/bin/podman pod create --name test ExecStartPre=/usr/bin/podman create --pod test --name containerA imageA ExecStartPre=/usr/bin/podman create --pod test --name containerB imageB ExecStart=/usr/bin/podman start test ExecStop=/usr/bin/podman stop test [Install] WantedBy=multi-user.target
It works when I fire off the commands manually, but when I try to start the service it becomes dead and the pod gets status Exited, killing the two containers inside it.
Again, when I run all the commands from the shell manually the pod comes up fine and runs without problems. Ideas? _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
When two containers belong to the same pod, they share the same network space. Therefore, there is no need for name resolution. They will both respond to localhost. On Fri, 2019-06-28 at 17:22 +0000, Christoffer Reijer wrote:
I also tried to access it on localhost which is how a pod works on kubernetes. But I don't run Kubernetes on this host so I'm not entirely sure how the "pod" philosophy works in this case when using podman.
I just want to create 2 containers on the same host using podman and having container A access a service on container B. Please help me, I do not want to resort to installing docker on RHEL 8 just because of something as trivial as this. :( _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
participants (6)
-
Brent Baude -
Christoffer Reijer -
Peter Hunt -
Robert P. J. Day -
Rémy Dernat -
Tom Sweeney