I am new to Docker and I was trying out a particular scenario for which I do not find any solution online or on forums.
The details on my setup is such that, I am using Docker 17.06 .1-ee-2 on Linux with a Swarm setup. I have a container which contains a Java process. As a program functionality, we shutdown the running Java program based on a few conditions so as to avoid further damage to the data and consistency of our program. Once detected that the Java program has gone down we manually bring it up by doing docker stack deploy.
My question was whether there is any functionality / signal / setting available in Docker which will kill the Container (self-destroy or self-rm) once its detects that the Java program running within it has shut down?
Currently, if the Java process has gone down, we can still see the Docker container in docker service ls which seems misleading because if the only process within the Container is not running then the Container should ideally be rm’ed as well or there should at least be a way to do it.
Thoughts / Pointers?