How to run two (or more) Pyramid apps in Docker on single VM?

30 views
Skip to first unread message

Steve Piercy

unread,
Jan 28, 2021, 8:25:34 AM1/28/21
to pylons-...@googlegroups.com
Howdy,

I want to run two versions of Deform Demo on a single VM in Docker containers. I've been able to successfully build the Docker containers for each version, but I do not know how to configure each Pyramid app (two versions of Deform Demo in this case) to run with nginx as the upstream proxy server. Has anyone done something similar, and if so, what must I configure to serve both apps?

I know it has something to do with port configuration (Deform v2 serves just fine, but v3 continuously restarts and nginx cannot find it), but I lack the knowledge and DuckDuckFu to figure out the details on my own.

--steve

Mike Orr

unread,
Jan 28, 2021, 11:28:24 AM1/28/21
to pylons-...@googlegroups.com
You could have the main process be Supervisord and have it launch two
instances of the Pyramid application, each with a different config
file. I just reviewed a Docker-Django setup, and it had several stages
in the Dockerfile. All of them launched Supervisord and copied all the
job files to the container, but each stage specified in an environment
variable which job files Supervisord should "include" in that
container.

I also have a Pyramid application that's run as two instances with
different config files (main and mobile). I have each one in a
different container using the same image, and a bind-mount directory
that has the config files and launch scripts, so each one specifies a
different launch script or config file on the command line.

I haven't done exactly what you're doing but it sounds like they could
run on different ports in the same container. I have to have them
running on different ports even in different containers. Apache is
running on the host, and the reverse proxies use the ports to access
the containers.
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/f51239cb-40c3-4f3d-d52a-7f82b7bce681%40gmail.com.



--
Mike Orr <slugg...@gmail.com>

Thijs

unread,
Feb 1, 2021, 2:59:38 AM2/1/21
to pylons-...@googlegroups.com
I have done this a few times, have you figured this out already or do you need a hand?
In my experience the best way to handle this is with docker-compose. You can configure multiple containers each with a different (internal) hostname. And then add a reverse proxy (I use nginx, but I have heard some great things about Traefik) to map the internal hostnames to external paths/ports.
Thijs

Message has been deleted

Steve Piercy

unread,
Feb 1, 2021, 4:07:33 AM2/1/21
to pylons-...@googlegroups.com
Thanks, I eventually did figure it out. I had to set up a unique port for each app. We use nginx, Docker containers, and Ansible to automate builds.

Docker:

published_ports:
- "8522:8000"

published_ports:
- "8523:8000"

nginx:

upstream backend_deformdemo {
server 127.0.0.1:8522 weight=1 max_fails=5 fail_timeout=30s;
}

upstream backend_deformdemo3 {
server 127.0.0.1:8523 weight=1 max_fails=5 fail_timeout=30s;
}

and success!

https://deformdemo.pylonsproject.org/
https://deformdemo3.pylonsproject.org/

--steve


On 1/31/21 11:59 PM, Thijs wrote:
> I have done this a few times, have you figured this out already or do you need a hand?
> In my experience the best way to handle this is with docker-compose. You can configure multiple containers each with a different (internal) hostname. And then add a reverse proxy (I use nginx, but I have heard some great things about Traefik) to map the internal hostnames to external paths/ports.
> Thijs
>
> On Thu, Jan 28, 2021 at 2:25 PM Steve Piercy <steve.pi...@gmail.com <mailto:steve.pi...@gmail.com>> wrote:
>
> Howdy,
>
> I want to run two versions of Deform Demo on a single VM in Docker containers.  I've been able to successfully build the Docker containers for each version, but I do not know how to configure each Pyramid app (two versions of Deform Demo in this case) to run with nginx as the upstream proxy server.  Has anyone done something similar, and if so, what must I configure to serve both apps?
>
> I know it has something to do with port configuration (Deform v2 serves just fine, but v3 continuously restarts and nginx cannot find it), but I lack the knowledge and DuckDuckFu to figure out the details on my own.
>
> --steve
>
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com <mailto:pylons-discuss%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/f51239cb-40c3-4f3d-d52a-7f82b7bce681%40gmail.com <https://groups.google.com/d/msgid/pylons-discuss/f51239cb-40c3-4f3d-d52a-7f82b7bce681%40gmail.com>.
>
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com <mailto:pylons-discus...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAHnCEofdYYBTpfqa_qJ3ibpJq0z94O1MZkRYSZFaCM1%3D_n4RRA%40mail.gmail.com <https://groups.google.com/d/msgid/pylons-discuss/CAHnCEofdYYBTpfqa_qJ3ibpJq0z94O1MZkRYSZFaCM1%3D_n4RRA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages