The spring container monitors if it is still used by `exec`
Since all processes run by docker-compose run
or exec
are parent of -ppid 0
we can use it to count how many
shells are in use.
If there are no shells (except run
) exit after some
grace period.
Output
Initially I run make shell
twice, then exited.
docker-compose logs -f spring
+ exec /scripts/startup/spring.sh
Used by 2 processes...
Used by 3 processes...
Used by 1 processes...
Retrying 1...
Used by 1 processes...
Retrying 2...
Used by 1 processes...
Retrying 3...
Used by 1 processes...
Retrying 4...
Used by 1 processes...
Retrying 5...
Used by 1 processes...
Retrying 6...
Used by 1 processes...
Retrying 7...
Used by 1 processes...
Retrying 8...
Used by 1 processes...
Retrying 9...
Used by 1 processes...
Retrying 0...
No more `docker-compose exec` running. Exiting
Edited by Kamil Trzciński (Back 2025-01-01)