Docker compose to start container Y once start up script from container X are executed completely

I am using docker-compose to spin up two containers as shown in below example. DB image has start up script which takes around 5 mins to get it’s execution completed.

Is there any way to start ‘web’ container once the start up script execution is finished from ‘db’ container?

    image: webapp
    - db
    image: db

Or lets say I have just one container and want to only start that container when the execution of start up script is finished,

I have referred this one.

in your ‘web’ container put a startup script which looks for the availability of the DB and brings your application up only once the DB is fully up. Let this startup script be your entry point. In the script you could sleep for a few seconds before trying to re connect to DB.