我有一个用于创建mysql镜像并将端口暴露到3306的docker-compose文件,但是当我尝试安装CMS时,它给出了无法连接到数据库的错误。我尝试扫描3306端口,它显示端口已打开,因此mysql正在运行。
为什么两个docker容器看不到彼此?
这是我的docker-compose文件:
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