Docker Compose connect ECONNREFUSED 172.18.0.4:3306(Docker Compose 连接 ECONNREFUSED 172.18.0.4:3306)
问题描述
当我用这个命令构建项目的容器时:
然后我通过这个 Docker-Compose 配置下载了 mysql 的镜像:
然后,项目将通过
我该如何解决这个问题?
Sequelize 配置是这样的:
网络的配置是这样的:
名为等待它"的脚本是 这个.
如果有人需要完整的代码,给你:
续集配置
Docker Compose 配置
Dockerfile 配置
wait-for-it.sh
默认等待15 秒 并返回,即使目标尚未准备好.您也可以在输出中看到这一点.但是数据库还没有准备好.制作 wait-for-it.sh
等待更长时间,也许用 -t 90
等待 90 秒或 -t 0
让它永远等待.
(根据我的经验,Docker 数据库容器通常需要 30-60 秒才能启动,尤其是第一次.)
When I build the container of the project with this command:
And then I download the mysql's image through this Docker-Compose config:
And then, the project will connect with MySQL through the Sequelize ORM
I have this error:
How can I resolve this?
The Sequelize config is this:
The config of the web is this:
The script called "wait for it" is this.
If someone needs the complete code, here you go:
Sequelize config
Docker Compose config
Dockerfile config
wait-for-it.sh
by default waits for 15 seconds and returns, even if the target isn't ready yet. You see that in your output too. But the database isn't ready yet. Make wait-for-it.sh
wait longer, maybe with -t 90
to wait for 90 seconds or -t 0
to make it wait forever.
(In my experience the Docker database containers routinely take 30-60 seconds to start up, especially the first time.)
这篇关于Docker Compose 连接 ECONNREFUSED 172.18.0.4:3306的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!