我正在努力與以下碼頭設置..一切運行在自己的罰款,但由於某種原因,我的nginx容器無法連接到MySQL之一,我已經其次在這個無數的教程和他們沒有爲我工作,所以任何的建議是優秀..我的碼頭工人撰寫如下(FPM和nginx的工作完全)..Docker Compose - 無法連接到MySQL從單獨的Nginx容器
# web server
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
# app
- ./app/src:/usr/share/nginx/html
# nginx configs
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d/:/etc/nginx/conf.d/:ro
- ./nginx/snippets/:/etc/nginx/snippets/:ro
# certificates
- ./nginx/letsencrypt/fullchain.pem:/etc/letsencrypt/live/example.com/fullchain.pem:ro
- ./nginx/letsencrypt/privkey.pem:/etc/letsencrypt/live/example.com/privkey.pem:ro
# logs
# - ./logs/nginx-error.log:/var/log/nginx/error.log
# - ./logs/nginx-access.log:/var/log/nginx/access.log
links:
- fpm:__DOCKER_PHP_FPM__
- db
# php-fpm
fpm:
build: ./php-fpm
ports:
- "9000"
volumes:
- ./app/src:/usr/share/nginx/html
- ./php-fpm/php-production.ini:/usr/local/etc/php/php.ini:ro
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: "admin"
ports:
- "3306:3306"
當我運行碼頭工人,組成了MySQL的噴出幾條有趣的線
db_1 | 2017-08-01T17:53:15.872664Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db_1 | 2017-08-01T17:53:15.872716Z 0 [Note] IPv6 is available.
db_1 | 2017-08-01T17:53:15.872723Z 0 [Note] - '::' resolves to '::';
db_1 | 2017-08-01T17:53:15.872736Z 0 [Note] Server socket created on IP: '::'.
db_1 | 2017-08-01T17:53:15.911242Z 0 [Note] mysqld: ready for connections.
db_1 | Version: '5.7.19' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
看起來不是這樣接受TCP連接並使用我的wp-config.php數據庫文件中的套接字地址也不起作用。
這基本上就是快到了上安裝WordPress屏幕:
Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /usr/share/nginx/html/wp-includes/wp-db.php on line 1538
有趣的是我可以從SequelPro或MySQL工作臺連接到數據庫沒有問題..即時通訊非常新的泊塢窗(和泊塢窗撰寫)所以也許我在這裏失去了一些東西或一步?
我正在osx上運行docker,如果這很重要的話。
泊塢窗PS輸出:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
060ac535e91e nginx:latest "nginx -g 'daemon ..." 9 minutes ago Up 9 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp dockerlnmpmaster_nginx_1
56db5e7bf9c1 mysql "docker-entrypoint..." 10 minutes ago Up 9 minutes 0.0.0.0:3306->3306/tcp dockerlnmpmaster_db_1
6b8d6e4bec5f dockerlnmpmaster_fpm "php-fpm" 10 minutes ago Up 9 minutes 0.0.0.0:32813->9000/tcp dockerlnmpmaster_fpm_1
你是如何從SequelPro或Workbench連接和你在'/ usr/share/nginx/html/wp- includes/wp-db.php'?? – VladoDemcak
它的怪異..我只是連接到127.0.0.1和端口3306 ..但是當我在wordpress中使用這些細節安裝它不工作.. – Kravitz
也當我撞到nginx容器和安裝curl它無法達到127.0.0.1 :3306要麼 – Kravitz