Starting a new container on the condition of stopping another container


Very new to the wonderful world of Docker so excuse my ignorance.

I want to automatically start a new container a quickly as possible when an old container stops. I am trying to minimise overall downtime. I have a container running an old piece of software which I need to stop before I can run my new software in another container so I want to have the new container up and running as soon as the old one has stopped with as little latency as possible between stopping the old one and running the new one.

I have a small program running inside a container that receives real-time data from a sensor. If I change some config or update to the software and run it in a new container I want to minimise real-time data loss between stopping the old container and starting the new container.

Thanks for any advice / help on this.