我尝试将 docker映像推Eclipse theia
送到 cf,但是无法启动它(或者更确切地说连接到它)。该图像使用 .公开端口 3000 EXPOSE 3000
。该应用程序工作并在本地运行它会打开默认的 theia 主屏幕
在 CF 上,提供了足够的磁盘和内存。设置默认port
健康检查后,cf 在启动应用程序时挂起。
Creating app theia-docker...
Mapping routes...
Staging app and tracing logs...
Cell 15fcfa4a-a364-4dc2-ab6b-349f5196bd80 creating container for instance bd4b9e65-946f-485a-9de1-5c7fc8d4ad01
Cell 15fcfa4a-a364-4dc2-ab6b-349f5196bd80 successfully created container for instance bd4b9e65-946f-485a-9de1-5c7fc8d4ad01
Staging...
Staging process started ...
Staging process finished
Exit status 0
Staging Complete
Cell 15fcfa4a-a364-4dc2-ab6b-349f5196bd80 stopping instance bd4b9e65-946f-485a-9de1-5c7fc8d4ad01
Cell 15fcfa4a-a364-4dc2-ab6b-349f5196bd80 destroying container for instance bd4b9e65-946f-485a-9de1-5c7fc8d4ad01
Cell 15fcfa4a-a364-4dc2-ab6b-349f5196bd80 successfully destroyed container for instance bd4b9e65-946f-485a-9de1-5c7fc8d4ad01
它最终来到FAILED
cf 日志将显示:
2021-06-12T14:37:25.40+0530 [APP/PROC/WEB/0] OUT root INFO Deploy plugins list took: 161.7 ms
2021-06-12T14:38:24.77+0530 [HEALTH/0] ERR Failed to make TCP connection to port 2375: connection refused; Failed to make TCP connection to port 2376: connection refused
2021-06-12T14:38:24.77+0530 [CELL/0] ERR Failed after 1m0.303s: readiness health check never passed.
为什么它使用错误的端口号?如果我尝试将 env 变量中的端口设置为cf set-env PORT 3000
,我会得到
FAILED
Server error, status code: 400, error code: 100001, message: The app is invalid: environment_variables cannot set PORT
然后我将健康检查设置为process
. 当然,这将成功启动(失败与否)。检查日志可以看到应用程序已经成功启动。当我ssh
进入应用程序 ( cf ssh theia-docker
) 时,我能够将应用程序卷曲为 localhost:3000 并返回主页的 HTML。
~ % cf ssh theia-docker
bash-5.0$ curl localhost:3000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="./bundle.js" charset="utf-8"></script>
</head>
<body>
<div class="theia-preload"></div>
</body>
</html>bash-5.0$
但是,当我尝试通过应用程序 URL 连接到应用程序时,出现错误:
502 Bad Gateway: Registered endpoint failed to handle the request.
我看到这个的原因是我用于此的基本映像是基于的,docker:dind
并且似乎在基本映像中,端口 2375 和 2376 已暴露。
为什么 CF 选择基础镜像中暴露的端口,而不是创建的 docker 镜像中暴露的端口?当前图像中的端口不应该优先吗?