I think that docker-compose run <service> should bring up the dependencies of that service, the same as docker-compose up <service> would. There is already the --no-deps flag for run, which implies that the default behavior is to bring up dependencies.
If this is the intended behavior, then I am not seeing it. If I have a docker-compose.yml file like this:
version: '2'
services:
web:
image: postgres
command: sh -c 'psql -h db -p 5432 -U postgres -d postgres -c "\list"'
entrypoint: /tmp/entrypoint.sh
volumes:
- ./entrypoint.sh:/tmp/entrypoint.sh
depends_on:
- db
db:
image: postgres
Then running docker-compose run web won't bring up the db container.
hmm, yes, we only look at links right now. I suppose it would make sense to include all the dependencies, not just links.
I think we can just change get_linked_service_names() to get_dependency_names() in compose/cli/main.py:run_one_off_container(), if anyone is interested in submitting a PR.
The run command also doesn't add the container that's being run to the networks that the compose file specifies it belongs to. You'll want to make sure the container joins those networks so its easier to run commands like docker-compose run rails bash and start pinging other containers to make troubleshooting applications a little easier.
@bradgessler Can you provide a failing case to reproduce that? Any container I run with docker-compose run seems to join the networks correctly.
@aanand I believe if you've never run up first the dependencies aren't there (unless you used links). I believe #2893 fixes it.
Hi folks!
Sadly, It seems that healthcheck is not used by docker-compose run with version 2.1…
Most helpful comment
Hi folks!
Sadly, It seems that
healthcheckis not used bydocker-compose runwith version2.1…