网络悬挂5秒钟的VS代码远程Docker容器
我有3个服务:WebApp(App),数据库(DB)和REDIS(RD)共享同一网络。 随机,与服务(数据库和REDIS)的两个连接均可悬挂5秒钟。 连接到数据库的网络服务器不仅在运行网络服务器时,即使我在网页上浏览链接时,也是如此。在某个时候,它冻结了,需要等待大约5秒钟。
我不确定,但是看起来连接在某个时候会自动关闭,需要重新建立。
我不知道我应该调试以下问题:
这是我的docker-compose文件:
version: "3"
services:
app:
depends_on:
- db
- rd
build:
context: ..
dockerfile: .devcontainer/service_app/Dockerfile
volumes:
- ..:/workspace:delegated
# Avoid having the container shut down if the default container command fails or exits
command: /bin/sh -c "while sleep 1000; do :; done"
db:
env_file: service_db/.env.local
build:
context: ..
dockerfile: .devcontainer/service_db/Dockerfile
volumes:
- "pgdata:/var/lib/postgresql/data"
rd:
image: redis:7
volumes:
- "rddata:/data"
volumes:
pgdata:
rddata:
我不明白会导致这一点。谢谢。
I have 3 services: webapp (app), database (db), and redis (rd) that share the same network.
Randomly, both connections to the services (database and redis) hangs about 5 seconds.
It's not only when I run my webserver that connects to the database, but even when I browse a link on a web page. At some point it freezes and need to wait for about 5 seconds.
I'm not sure but it looks like the connection is automatically closed at some point and need to be re-established.
I don't know I'm supposed to debug this:
- Running
telnet db 5432
ortelnet rd 5432
in my app container will always work instantly. - Running docker ps -a in my host machine display this:
Here is my docker-compose file:
version: "3"
services:
app:
depends_on:
- db
- rd
build:
context: ..
dockerfile: .devcontainer/service_app/Dockerfile
volumes:
- ..:/workspace:delegated
# Avoid having the container shut down if the default container command fails or exits
command: /bin/sh -c "while sleep 1000; do :; done"
db:
env_file: service_db/.env.local
build:
context: ..
dockerfile: .devcontainer/service_db/Dockerfile
volumes:
- "pgdata:/var/lib/postgresql/data"
rd:
image: redis:7
volumes:
- "rddata:/data"
volumes:
pgdata:
rddata:
I don't understand what could cause this. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试用
tail -f/dev/null
替换睡眠环路Try to replace your sleep loop with
tail -f /dev/null