A normal depends_on is strict: if the dependency is missing, Compose refuses. The long syntax has a required field that makes it a soft dependency.
services:
app:
image: example/app:1.0
depends_on:
cache:
condition: service_started
required: false
cache:
image: redis:7-alpine
profiles: ["cache"]
When the cache profile is active, Compose starts Redis before the app, as usual. When it is not, the app starts on its own and Compose only prints a warning instead of an error. The default is required: true.
I like this together with profiles. Optional extras such as a cache, a metrics exporter or an admin UI can be switched on per machine, and the main service does not care either way.
The app itself still has to cope when the cache is not there. Compose only handles the start order; if the code crashes when it cannot reach Redis, required: false just moves the error from Compose to your logs. The field needs a reasonably recent Compose version, so check with docker compose config that yours keeps it.
Further reading: Compose file reference: depends_on