且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Gitlab CI runner 无法暴露嵌套 Docker 容器的端口

更新时间:2023-10-18 17:19:28

官方 gitlab.com 文档上的 gitab-ci 指的是 PostgreSQL 示例

其工作 CI 不会尝试连接到 localhost,而是连接到 服务名称

Its working CI does not try to connect to localhost, but rather to the service name

services 关键字仅定义另一个在构建期间运行的 docker 镜像,并链接到 image 关键字定义的 docker 镜像.这允许您在构建期间访问服务映像.

The services keyword defines just another docker image that is run during your build and is linked to the docker image that the image keyword defines. This allows you to access the service image during build time.

可以在主机名mysql下访问MySQL的服务容器.
因此,为了访问您的数据库服务,您必须连接到名为 mysql 的主机,而不是套接字或 localhost.

The service container for MySQL will be accessible under the hostname mysql.
So, in order to access your database service you have to connect to the host named mysql instead of a socket or localhost.

您可以检查这是否适用于您的情况,并尝试在 app:9143 而不是 localhost:9143 中访问您的应用程序服务.

You could check if this applies in your case, and try accessing your application service in app:9143 instead of localhost:9143.