ctop showing multiple processes

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

Requirements

Docker image creation

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.

Process with dependencies and type of run

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

cron

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

nginx unit

Steps:

docker-entrypoint

Steps:

Entrypoint

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

The repository: xmltv_tnt_json_unit