Skip to content

Instantly share code, notes, and snippets.

@jimanx2
Last active September 12, 2025 01:08
Show Gist options
  • Select an option

  • Save jimanx2/d6db95e592c31b94f94e4303b0cf2987 to your computer and use it in GitHub Desktop.

Select an option

Save jimanx2/d6db95e592c31b94f94e4303b0cf2987 to your computer and use it in GitHub Desktop.
(b)ash script to automatically run extra scripts before the actual docker entrypoint
#!/bin/sh
# depends on env first, if none,
# fall back to /etc/docker-entrypoint/init.d
ENTRYPOINTS_D=${ENTRYPOINTS_D:-/etc/docker-entrypoint/init.d}
# ensure entrypoints dir exists
mkdir -p /etc/docker-entrypoint/init.d
# load all .sh files according to glob sequence
for initscript in $(find $ENTRYPOINTS_D -maxdepth 1 -type f -name "*.sh" | sort); do
sh $initscript > /dev/stdout 2>/dev/stderr
done
# once done, exec the actual intended script
exec $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment