Closed hbielenia closed 4 years ago
The default Docker bridge
network doesnt allow for inter-container hostname resolution, you want a user defined one
https://docs.docker.com/network/bridge/#differences-between-user-defined-bridges-and-the-default-bridge
Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias.
Following instructions on https://hub.docker.com/_/mariadb, I do the following:
docker run --name mariadb -e MYSQL_ROOT_PASSWORD=pass mariadb:10.1
docker inspect mariadb
, I see it connects to defaultbridge
network:docker run -it --network bridge --rm mariadb:10.1 mysql -hmariadb -uroot -p
, I get the password prompt and after filling inpass
, I get the error:ERROR 2005 (HY000): Unknown MySQL server host 'mariadb' (-2)