Containerization pattern best practice
<p>I am dockerizing a Python webapp using the <a href="https://hub.docker.com/r/tiangolo/uwsgi-nginx" rel="nofollow">https://hub.docker.com/r/tiangolo/uwsgi-nginx</a> image, which uses supervisor to control the uWSGI instance.</p>

<p>My app actually requires an additional supervisor-mediated process to run (LibreOffice headless, with which I generate documents through the <code>appy</code> module), and I'm wondering what is the proper pattern to implement it.</p>

<p>The way I see it, I could extend the above image with the extra supervisor config for my needs (along with all the necessary OS-level install steps), but this would be in contradiction with the general principle of running the least amount of distinct processes in a given container. However, since my Python app is designed to talk with LibreOffice only locally, I'm not sure how I could achieve it with a more containerized approach. Thanks for any help or suggestion.</p>

<p>The recommendation for one-process-per-container is sound - Docker only monitors the process it starts when the container runs, so if you have multiple processes they're not watched by Docker. It's also a better design - you have lightweight, focused containers with single responsibilities, and you can manage them independently.</p>

<p><a href="http://stackoverflow.com/users/2105103/user2105103">user2105103</a> is right though, the image you're using already loses that benefit because it runs Python and Nginx, and you could extend it with LibreOffice headless and package your whole app without changing code.</p>

<p>If you move to a more "best practice" approach, you'd have a distributed app running across three containers in a Docker network:</p>

<ul>
<li><code>nginx</code> - web proxy, this is the public entry point to the app. Nginx can do routing, caching, SSL termination, rate limiting etc. </li>
<li><code>app</code> - your Python app, only visible inside the Docker network. Receives requests from <code>nginx</code> and uses <code>libreoffice</code> for document manipulation;</li>
<li><code>libreoffice</code> - running in headless mode with the API exposed, but only available within the Docker network.</li>
</ul>

<p>You'd need code changes for this, bringing in something like <a href="https://pypi.python.org/pypi/pyoo" rel="nofollow">PyOO</a> to use the LibreOffice API remotely from the app container.</p>

python nginx docker uwsgi supervisord