Compose commands only work inside the project folder, or with the right -f and -p. When you forgot where a stack lives, docker compose ls tells you.
docker compose ls
docker compose ls -a
It lists the Compose projects that are currently running, with the status and the path of the config file. -a (--all) includes stopped projects as well, which matters when you want to find something you shut down months ago.
The output has more options. --format json gives machine-readable output, -q prints just the project names and --filter narrows the list, for example by status.
docker compose ls --format json
The config file path is the useful part: from there you can cd to the folder, or run docker compose -f /path/to/compose.yaml ps from anywhere.
The caveat is that the list only knows projects that Compose started, based on the labels it puts on containers. A container that was started with plain docker run is not listed, and a project whose containers were removed manually disappears from the list even if the compose file is still on disk. In that case look for the folder yourself.
Further reading: docker compose ls reference