Reputation: 424
I have a docker compose file which works fine with these commands:
docker-compose up
docker-compose exec web /bin/bash
The issue I have is that when I want to start the container with --service-ports I can't connect to the container anymore with docker-compose.
docker-compose run --service-ports web
docker-compose exec web /bin/bash
ERROR: No container found for web_1
I also tried:
docker-compose run --service-ports --name container_web --rm web
docker-compose exec web /bin/bash
ERROR: No container found for web_1
# this works
docker exec -it container_web /bin/bash
root@b09618ad2840:/code/app#
Any help will be very much appreciated.
Thanks
Upvotes: 1
Views: 1721
Reputation: 10727
According to the documentation, docker-compose run
is used to "Run a one-off command on a service".
For this reason you cannot split your actions in run + exec.
This will work:
docker-compose run --service-ports web /bin/bash
You should use docker-compose up
to start your services instead of docker-compose run
.
Upvotes: 3