Mysql client called with `docker-compose run` vs. `docker-compose exec`

Viewed 1761

Why do you need to specify a host when calling with docker-compose run?

e.g.

docker-compose run db_container mysql -uuser -ppass db_name -h db_container

seems to be the direct equivalent of

docker-compose exec db_container mysql -uuser -ppass db_name

When omitting the hostname flag from the first example, mysql fails with a "can't connect to socket" error.

What is the difference between the two examples?

1 Answers
Related