Since you run it separately (-d), docker-compose only spawns containers and exits without controlling any problems. If you run containers in the foreground, follow these steps:
docker-compose up --abort-on-container-exit
This should give you a pretty clear error for any problems with the container. Otherwise, I would recommend exploring some other more advanced schedulers that track running containers for crash recovery (like Universal Control Plane or Kubernetes).
Update. If you want a script for something outside docker-compose up -d, you can do
docker events -f "container=${compose_prefix}_" -f "event=die"
and if something is displayed there, you will have a container. There also docker-compose events | grep "container die".
source
share