我从docker开始,并且在进行正确配置时遇到一些问题。 框架需要一个脚本来使后端工作。 这需要一个sql连接。我找到了一种让phpmyadmin工作的方法,但脚本无法连接mysql数据库。 如果有更多Docker理解的人可以在出现问题时给我一个提示。
myhomepage-mysql:
image: mysql:5.7
container_name: myhomepage-mysql
environment:
- MYSQL_ROOT_PASSWORD=toor
- MYSQL_DATABASE=MyHomepage
- MYSQL_USER=homepage_admin
- MYSQL_PASSWORD=admin123
myhomepage-webserver:
image: phpdockerio/nginx:latest
container_name: myhomepage-webserver
volumes:
- ..:/var/www/myhomepage
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"
links:
- myhomepage-php-fpm
myhomepage-php-fpm:
build: .
dockerfile: php-fpm/Dockerfile
container_name: myhomepage-php-fpm
volumes:
- ..:/var/www/myhomepage
- ./php-fpm/php-ini-overrides.ini:/etc/php/7.1/fpm/conf.d/99-overrides.ini
links:
- myhomepage-mysql
myhomepage-phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: myhomepage-phpmyadmin
environment:
PMA_USER: root
PMA_PASSWORD: toor
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: toor
ports:
- "8181:80"
volumes:
- /sessions
links:
- myhomepage-mysql:mysql
第二个问题是phpmyadmin给出了这条消息:
Your PHP MySQL library version 10.1.20-MariaDB differs from your MySQL server version 5.7.17. This may cause unpredictable behavior.
我可以从http://localhost:8080/phpmyadmin访问phpmyadmin而不是http://localhost:8181/吗?
答案 0 :(得分:0)
目前此配置工作:
project-nginx:
container_name: project-webserver
image: nginx:latest
volumes:
- ..:/var/www/project
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./nginx/phpmyadmin.conf:/etc/nginx/conf.d/phpmyadmin.conf
ports:
- 80:80
links:
- project-php
- project-phpmyadmin
project-php:
build: .
dockerfile: php-fpm/Dockerfile
container_name: project-php
expose:
- 9000
volumes:
- ..:/var/www/project
- ./php-fpm/php-ini-overrides.ini:/etc/php/7.1/fpm/conf.d/99-overrides.ini
links:
- project-mysql
project-mysql:
image: mysql
container_name: project-mysql
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=toor
- MYSQL_DATABASE=project
- MYSQL_USER=project_admin
- MYSQL_PASSWORD=admin123
project-phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: project-phpmyadmin
environment:
- "PMA_HOST: project-mysql"
- "PMA_USER : root"
- "PMA_PASSWORD: toor"
links:
- project-mysql:db
volumes:
- /sessions
- ./phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php