我正在使用带有sequelize,docker和mysql的节点编写应用程序。尝试连接序列时,我某种程度上仅限于使用端口3306,如果更改“ config.db.details”中的端口,则会出现以下错误:
Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 172.18.0.5:3300
连接到sequelize时,我使用以下配置:
config.db = {
user: 'root',
password: 'pass',
name: 'ticketgo'
};
config.db.details = {
host: 'database',
port: 3300
};
Docker.yml文件:
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
client:
build: ./client
ports:
- "3001:3000"
volumes:
- "./client:/app"
environment:
- VIRTUAL_HOST=ticketgo.local
server:
build: ./server
ports:
- "3000:3000"
volumes:
- "./server/src:/app/src"
links:
- "database"
environment:
- VIRTUAL_HOST=api.ticketgo.local
database:
image: mysql
environment:
MYSQL_DATABASE: "ticketgo"
MYSQL_ROOT_PASSWORD: "pass"
volumes:
- "./sql:/docker-entrypoint-initdb.d"
adminer:
image: "adminer"
ports:
- "4444:8080"
links:
- "database"
非常感谢您的帮助!
答案 0 :(得分:0)
需要为数据库设置端口:
database:
image: mysql
environment:
MYSQL_DATABASE: "ticketgo"
MYSQL_ROOT_PASSWORD: "pass"
volumes:
- "./sql:/docker-entrypoint-initdb.d"
ports:
- "3306:3300"