I have a docker-compose file specifying multiple services such as application, server, redis and database. When I want to access them I do docker-compose exec application bash
or docker-compose exec server bash
. But when I do a docker-compose exec redis sh
I get the error ERROR: No such service: redis
. I can however access it by doing docker exec -it smb-redis sh
instead. What's the difference? Why can I access some of my running services, but not others using that command?
service name and image name could be different. I could have a below docker-compose.yml
version: "3"
mysql:
image: redis
And then to get into redis I will need to use
docker-compose exec mysql sh
So the service name matters and not what that service is actually running. The image name could be redis or mysql or anything else for that matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With