dsy1971
2018-03-13 10:47
浏览 927

如何使用Docker连接php-apache和MySQL?

I have a Wordpress site on live server and I want to create a LAMP stack locally with Docker to test things.

I pull the images of php:7.0-apache and mysql:5.7, the same versions on live.

I create a MySQL container:

docker run -d --name achi-mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7

I create a php & apache container and link it with MySQL:

docker run -d --name achi-php-apache --link achi-mysql:mysql -p 8080:80 -v /home/achi/workspace/web/wordpress-template/:/var/www/html php:7.0-apache

I get the following error on localhost:8080:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/html/wp-includes/wp-db.php:1564 [...]

Do I link these two containers the wrong way?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题