我有docker-compose文件來創建mysql映像並將端口暴露給3306,但是當我嘗試安裝CMS時,它給我錯誤,它無法連接到數據庫。我嘗試掃描端口3306,它顯示它已經打開,所以mysql正在運行。碼頭工人mysql無法連接到容器
爲什麼兩個碼頭集裝箱看不到對方?
這裏是我的搬運工,撰寫文件:
phpfpm:
restart: always
extends:
file: php-fpm-5.6.yml
service: phpfpm
links:
- db:db
nginx:
restart: always
image: nginx
ports:
- "8000:80"
links:
- phpfpm:phpfpm
volumes:
- ./nginx/vhost.conf:/etc/nginx/conf.d/default.conf
- ./app:/var/www/html
- ./log/nginx:/var/log/nginx
db:
restart: always
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: database
我嘗試在服務器上,並與固定的IP,這是很好的。但是localhost/127.0.0.1有什麼問題? –