Just a mysql client, without an additional docker container
Install the mysql client on your host,
apt-get install mysql-client
then use the following command to access the database container.
mysql -u<user> -p<pass> -h $(docker inspect --format '{{ .NetworkSettings.IPAddress }}' <db-container>)
The team will automatically get the IP address of your docker container.
Be sure to replace <user> , <pass> and <db-container> with the appropriate values. In your case:
mysql -uroot -ptest -h $(docker inspect --format '{{ .NetworkSettings.IPAddress }}' db)
Your command allows mariadb to run on standard port 3306. If not, you must tell the mysql command the new port.
source share