Create a script and save it as a bash file that contains the following:
$CONTAINER_NAME="someNameHere" docker exec -it $CONTAINER_NAME bash -c "sh script-exit.sh" docker stop $CONTAINER_NAME
Run this file instead of running docker stop , and this should do the trick. You can also set up an alias.
As for automating it inside Docker itself, I've never seen this before. Good luck figuring this out if this is the road you want to take.
source share