yield
yield

Reputation: 274

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

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 ?

Upvotes: 5

Views: 3622

Answers (2)

yamenk
yamenk

Reputation: 51758

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}')

Upvotes: 4

Fiber Optic
Fiber Optic

Reputation: 194

If your mysql is on your host, without a domain name, you won't be able to access it from a container. Maybe with a bridged network. You should try to move the database to a container. It will be super easy to connect the phpmyadmin then.

Upvotes: 0

Related Questions