@pedro47, I have remote connection from a
mysql client on my OSX machine working to a container inside the Docker Machine VM, here’s what I did to get it to work.
docker cp-ed the
/etc/mysql/my.cnf from an existing container and baked a new image with following the instructions to remove
bind-address line indicated here: https://mariadb.com/kb/en/mariadb/configuring-mariadb-for-remote-client-access/
As also indicated by that link, once I ran the container with the new configuration image I did a
docker exec and ran some SQL to grant privileges to
root user enabling remote connection.
SELECT User, Host FROM mysql.user WHERE Host <> 'localhost' indicated a
root user allowed to connect from everywhere, so I followed up with:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Then, I was able to connect with MariaDB client on my Macbook. The port is arbitrary due to my use of
docker run -P but you should be able to connect to
3306 if that’s the one you’re exposing.
$ mysql -h $(docker-machine ip) -P 32768 -u root -p
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.1.13-MariaDB-1~jessie mariadb.org binary distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
| Database |
| information_schema |
| mysql |
| performance_schema |
3 rows in set (0.00 sec)
Remember, this will expose the database to connection from all places, you should be careful to lock this down more carefully if you end up moving it into higher environments.