Created
June 13, 2025 11:59
-
-
Save jpbochi/ba01d87a9c6faf4851d96b4f38334a36 to your computer and use it in GitHub Desktop.
docker-run-loop-prevention.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prevent infinite loops - run `exec` when executed from within the container | |
# for containers started with --init | |
[ "$(cat /proc/1/comm)" == "docker-init" ] && exec env -- "$@" | |
# for other containers - inspired by https://github.com/starship/starship/blob/master/src/modules/container.rs#L58 | |
[ "$(cat /run/systemd/container)" == "docker" ] && exec env -- "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment