It would be helpful to be able to specify an internal command that should be called before a container is stopped.
With “classic” Docker, it is always possible to first perform a
docker exec [my command] on a container before stopping it. Which is not possible with containers handled by Services when the numbers of replicas are decreased.
That instruction should be declared the same way as the CMD one (in the Dockerfile, docker-compose, CLI, etc.).
The “–time int Seconds to wait for stop before killing it (default 10)” parameter should also be available through the configuration files to allow sufficient time to that command to succeed.