Execute script before starting service in docker-compose

Sometimes you need to execute shell commands before starting service in docker compose. You can create oneshot service using the image you need for those commands, entrypoint /bin/sh and shell commands in command option. YAML multi-line syntax allows to conviniently place the script inside docker-compose.yml . Use set -x to get verbose logs of script execution. Don’t forget that the last command…