Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect phpMyAdmin docker image to the HOST MySQL server listening only on 127.0.0.1

Tags:

I am looking to connect a PhpMyAdmin running in a container (Docker) to a MySQL server running on the host and listening on 127.0.0.1.

However, when I give docker the varuable -e PMA_HOST=127.0.0.1, it only look on it's own Docker network... How would I be able to talk to my host MySQL DB server ?

like image 886
yield Avatar asked Dec 03 '17 13:12

yield


People also ask

How do I connect to a MySQL Docker container?

Here are the steps you can follow to install the Dockerhub MySQL Container: Step 1: Pull the Docker Image for MySQL. Step 2: Deploy and Start the MySQL Container. Step 3: Connect with the Docker MySQL Container.

How do I run phpMyAdmin and Docker in MySQL?

You only need to open your favourite browser and type the following url: http://localhost:8081/ so your instance of phpMyAdmin will show up. To access, type root as username and the password you established in the step one when running the mysql container (if you followed the tutorial the password is mypass123).


1 Answers

You shouldn't use 127.0.0.1 as IP address to refer to the host as that will point to the docker container where phpAdmin is running.

You need to find the IP address of the host on the docker0 interface as use that ip instead. You can do that using:

-e PMA_HOST=$(ip route show | grep docker0 | awk '{print $9}')
like image 188
yamenk Avatar answered Sep 23 '22 13:09

yamenk