我正在尝试link
mysql和php / nginx docker容器。
这是我正在运行的用于连接容器的命令:
docker run -p 127.0.0.1:3005:80 --name nginxTest --link mysqlTest ubuntu
php容器包含以下php文件:
<?php
$servername = "mysqlTest";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
但是访问127.0.0.1:3005
时出现此错误:
Connection failed: MySQL server has gone away
我在做什么错了?