I've created a docker container containing an instance of mariadb, but i cannot access to the database from my phisical machine:
I've got the ip address from docker inspect and the port from docker ps but Sequel Pro gave me the connection failed message (same thing with Visual Studio Code). Obviously from inside the docker container I can connect myself to the database engine.
Where am i wrong? Thanks so much to everyone! :)
[EDIT] Thanks to all comments...
if I try to expose the port, the container doesn't run :/
It's worked for me:
docker container run \
--name sql-maria \
-e MYSQL_ROOT_PASSWORD=12345 \
-e MYSQL_USER=username \
-e MYSQL_PASSWORD=12345 \
-e MYSQL_DATABASE=dbname \
-p 3306:3306 \
-d mariadb:10
docker container logs -f sql-maria
The tail of the log should look something like this
2020-02-04 20:02:44 0 [Note] mysqld: ready for connections.
mysql -h 127.0.0.1 -p -u username dbname
If you are on a unix-based system it is mandatory to use the loopback address 127.0.0.1 instead of localhost
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