我是先啟動MariaDB後,再啟動phpMyAdmin,指令如下
$ docker run -it --name phpmyadmin -p 80:80 --link mariadb -d phpmyadmin/phpmyadmin
得到如下圖錯誤
節錄錯誤輸出的部分
mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known
解決辦法請詳閱 Docker Hub的 phpMyAdmin image 說明
You can specify MySQL host in the PMA_HOST environment variable. You can also use PMA_PORT to specify port of the server in case it’s not the default one:
docker run –name myadmin -d -e PMA_HOST=dbhost -p 8080:80 phpmyadmin/phpmyadmin
故改成以下指令就可以了
$ docker run -it --name phpmyadmin -p 80:80 --link mariadb -e PMA_HOST="mariadb" -d phpmyadmin/phpmyadmin