Container with multiple processes

Container with multiple processes

·

2 min read

Last week, I needed to create a docker image doing a simple thing:

  • downloading 1 XML file
  • converting it to JSON
  • serve both files

But I've a hard part: every 15 minutes, I need to look if a new version of the XML file is available and in case, running the entire process.

Let's go to see how I did it

I use Python container based on alpine linux as the base, adding an environment variable to avoid PIP cache.

To have multiple processes inside the contianer, I use s6-overlay and I think to rewrite the global path because by default it's not including the path where Python binaries (pip, python) are installed.

S6-overlay permits to define dependencies between processus and it's exactly what I need because:

  • docker-entrypoint needs to run before running the real nginx daemon but without persistance, it's a oneshot at boot
  • cron daemon needs to run in background and has 0 dependency
  • nginx unit needs to run in background when docker-entrypoint has ended the configuration

To setup cron, we have few steps inside the Dockerfile:

Steps:

Steps:

Finally, we'll use s6 has the entrypoint for this container

The repository: xmltv_tnt_json_unit