简体   繁体   English

Gitlab CI Runner Docker Executor公开端口

[英]Gitlab CI Runner Docker Executor Expose Ports

I have gitlab ci and gitlab containers. 我有gitlab ci和gitlab容器。 A project is registered with gitlab runner using docker executor. 使用docker executor在gitlab runner中注册了一个项目。 Everything is OK. 一切都好。 I set privileged mode true. 我将特权模式设为true。 There are flags about docker run such as volume share , privileged mode, image , service , link etc. But i could not find the flags in the runner.dockers section about port expose. 有关于docker run的标志,例如卷共享,特权模式,图像,服务,链接等。但是我找不到有关端口公开的runner.dockers部分中的标志。 My aim is to run a pipeline with container can communicate its ports. 我的目标是运行一个带有容器的管道可以与其端口进行通信。

Is it possible to implement this issue with gitlab runner ci. 是否可以使用gitlab runner ci实现此问题。

Normally that's what services are for. 通常这就是服务的用途。 You'd take a container that you want to expose ports on and define it as a service. 您将获取要在其上公开端口的容器并将其定义为服务。 That way, there are no exposed ports, but there is a service link which you can use for inter-container communication. 这样,没有暴露的端口,但是有一个服务链接可用于容器间通信。 That's valid for the Docker executor, in a Kubernetes executor all services are part of the pod and therefore available directly on the localhost . 这对Docker执行程序有效,在Kubernetes执行程序中,所有服务都是pod的一部分,因此可以直接在localhost

In other words: if, for example, you need a PostgreSQL for your build job running on its default port of 5432, you just start postgres:latest as a service for your job. 换句话说:例如,如果您的构建作业需要PostgreSQL在其默认端口5432上运行,那么您只需启动postgres:latest作为您的工作服务。 You can then reference it via postgres:5432 with a Docker executor and localhost:5432 with Kubernetes executor. 然后,您可以通过postgres:5432引用它postgres:5432使用Docker执行程序, localhost:5432使用Kubernetes执行程序。

If services do not fit your use case, you might want to expand your question as to where they fail, there might an alternative answer. 如果服务不适合您的用例,您可能希望扩展您的问题以确定它们失败的位置,可能还有其他答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM