Home > Net >  Connection to MariaDb within docker container and mysql workbench
Connection to MariaDb within docker container and mysql workbench

Time:05-03

I created a docker container that's running MariaDb using the command below:

docker run -d --name some-mariadb -p 3306:3306 -e MARIADB_USER=example-user -e MARIADB_PASSWORD=<enter password> -e MARIADB_ROOT_PASSWORD=<enter password>  mariadb 

I'm not able to successfully test the connection in mysql workbench when putting in the IPAddress (found it by running the docker command below) along with the user (example-user) and password (tried the passwords for MARIDB_PASSWORD and MARIADB_ROOT_PASSWORD).

All I get is "unable to connect to host"

Docker command to get IPAddress:

docker container inspect some-mariadb

Note that when I run the command below I am able to see the MariaDB [(none)]> terminal.

docker exec -it some-mariadb mysql -u example-user -p

CodePudding user response:

The IP address you get by container inspect is from the docker subnet.

Since you exposed the port of the mariadb container, you should be able to access it at DOCKER_HOST_IP_ADDRESS:3306

CodePudding user response:

I was able to create a connection using the localhost (127.0.0.1) IP address. The user and MARIADB_ROOT_PASSWORD had no issue.

  • Related