我已经在容器中安装了PHP,并在其中安装了本地文件和数据库。一切都在容器内进行。我也可以和mysql通讯,但是使用ip时它不起作用(显示无法连接到数据库)。
version: "3"
services:
webserver:
build:
context: ./bin/webserver
container_name: 'png-webserver'
restart: 'always'
ports:
- "81:81"
- "444:444"
volumes:
- /var/www/vhost/dev.x.com:/var/www/html
- ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
- ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
- ${LOG_DIR-./logs/apache2}:/var/log/apache2
- /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock