Running through the docker-compose walkthrough.
At one point it says
The docker-compose run command allows you to run one-off commands for your services. For example, to see what environment variables are available to the web service:
$ docker-compose run web env
When I first ran this my 2nd bash terminal was open in a different directory:
$ docker-compose run web env
ERROR: No such service: web
Odd, so I ran
$ docker-compose ps
Name Command State Ports
------------------------------
I was perplexed. So I ran the command in the other window:
ā docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------
composetest_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
composetest_web_1 python app.py Up 0.0.0.0:5000->5000/tcp
OK. What's the difference? Oh, the directory.
The thing I don't get is: why? Isn't docker-compose ps talking to a service to figure out who's running? Clearly not. So what's happening here? Best guess is that docker is reading the compose file then using the names of the services etc to filter the list of running docker images. It's just a bit surprising that it wouldn't return all the running containers if it didn't find a compose file in the same directory that the command is being run in.