Optimize the use of subprocess

Another fix from Claudyus' repository, this one reduces the amount of calls to subprocess in generating the index page, from once per container, to once for all containers.