How to get PHPMyAdmin to see MySQL in two different docker instance

I am trying to start a MySQL docker instance, and want to interface to this server with PHPMyAdmin.

My server host name from where docker is running is <ServerName>

I am using the following command to start my MySQL docker container

docker run -P --name mysql-test -v storage-test:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=MyDataBase -e MYSQL_USER=me -e MYSQL_PASSWORD=mepass -d mysql:latest

And it seems to start and create the database correctly
after that i start PHPmyAdmin container

docker run --name myadmin -d -e MYSQL_ROOT_PASSWORD=root -e PMA_HOST=ServerName -e PMA_VERBOSE=MyDataBase -e PMA_USER=me -e PMA_PASSWORD=mepass  -p 8080:80 phpmyadmin/phpmyadmin

I get this log from mySql container

MySQL init process done. Ready for start up.

2019-10-01T11:36:35.909758Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2019-10-01T11:36:35.909856Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 1
2019-10-01T11:36:37.735204Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-10-01T11:36:37.761004Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-10-01T11:36:37.776949Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.17'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2019-10-01T11:36:37.887863Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

However when I access the PHPMyAdmin weblogin I get the following Error:

  • MySQL said: Documentation
    Cannot connect: invalid settings.
  • mysqli_real_connect(): (HY000/2002): Connection refused
  • phpMyAdmin tried to connect to the MySQL server, and the server
    rejected the connection. You should check the host, username
    and password in your configuration and make sure that they
    correspond to the information given by the administrator of the
    MySQL server.

If I remove the -e PMA_USER=me -e PMA_PASSWORD=mepass from the run command I get to the login where I can enter my credentials however when trying to do that I just get the

  • mysqli_real_connect(): (HY000/2002): Connection refused

Can anyone see what I’m doing wrong here ?

Here is a link to the two docker containers I am using


Source: StackOverflow