Running a bash script outside of docker container as part of the docker-compose process

As an alternative solution you might be able to do this using systemd services. On TorizonCore there is a service that runs on boot that starts the docker-compose file located at /var/sota/storage/docker-compose/.

This is the service here: meta-toradex-torizon/docker-compose.service at dunfell-5.x.y · toradex/meta-toradex-torizon · GitHub

You could modify or override this service to add the ExecStartPre field as described here: systemd.service

This field will run before the main ExecStart command defined in this service. In this way it may be possible to run your script before your compose file is brought up.

Best Regards,
Jeremias