Docker version 24.0.4, build 3713ee1
docker-compose version 1.29.2, build unknown
Hi folks,
I have two docker-compose.yml files in different folders (not nested with each other). When I run docker-compose ps in folder A, I see the running postgres container showing up from folder B. Essentially, docker-compose ps is showing running containers that are not defined in the compose file in the current directory. How is this possible? Please help.
docker compose never really cared for folders, it cares for the project name. So if compose files declare the same project name, or the compose command specifies the same project name, then it would make sense… though docker compose should complain about orphaned services in this scenario. The folder name is used as project name, in case no project name is provided. Though, you can have multiple compose files in the same folder and deploy them by specifying different project names. You can also deploy the same compose file using different project names (if collision of published host ports does not prevent it).
Also make sure to use docker compose and not docker-compose as the latter has been deprecated a while ago.