Queue processes for images being built & deployed using docker-compose

Hello,

Anyone know of a way that I can queue up images from being built & deployed? We are currently using Jenkins pipelining for defining the steps that must be taken in order for an image to be built and deployed in development. There can only be a maximum of five containers running at a time and we are currently using shell scripts to basically loop and wait until there are less than five containers running. There is a separate script that runs and purges any containers running over a certain amount of time.

I think the best way would be to use some sort of implementation of a queue that is invoked whenever there are five or more containers running. Whenever a container is purged, then the next image in the queue is built and deployed. I’m couldn’t really find any plugins or anything that would accomplish this. I am pretty new to docker so this might not be the clearest explanation but any ideas or help would be appreciated.

Thank you