Comments - Installing and Using MariaDB via Docker

 
2 years, 11 months ago Mikhail Klemin

I tried the example on Ubuntu 21.04. It was not working

mysql -h 172.17.0.2 -P 3306 --protocol=TCP -u root -p
ERROR 2002 (HY000): Can't connect to MySQL server on '172.17.0.2' (115)

Changing to

mysql -h 127.0.0.1 -P 3306 --protocol=TCP -u root -p

made it work

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.5.12-MariaDB-1:10.5.12+maria~focal mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
 
4 years ago Taran Goyal

If we need to specify port, datadir, or tmpdir etc in the docker my.cnf, how can we provide this if persistent storage is being used?

 
3 years, 8 months ago Federico Razzoli

Hi Taran. You can use volumes for /etc/mysql, for /var/lib/mysql/data, etc. So these directories are persistent, and you can easily edit your my.cnf setting the proper paths. I'm not completely sure this answers your question, so please let me know if you still have doubts.

 
3 years, 7 months ago Anel Husakovic

You can create a network and start detached process on that network, since bridge network doesn't work.

After that you can connect from different container running mysql like this:

$ docker network create mariadb-net
$ docker run --net mariadb-net --name mariadb-c1 -e MYSQL_ROOT_PASSWORD=root -d mariadb:10.5

$docker run -it --network mariadb-net --rm mariadb:10.5 mysql -hmariadb-c1 -uroot -proot

Federico if you are ok with this, I can update the wiki.

 
8 years, 9 months ago Gary Schultz

I'm just getting started with Docker and containers. Despite being specific to MariaDB this knowledge provided me with a few additional insights into Docker that are missing from other Docker resources. Great job.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.