简体   繁体   中英

Gitlab CI Runner Docker Executor Expose Ports

I have gitlab ci and gitlab containers. A project is registered with gitlab runner using docker executor. Everything is OK. I set privileged mode 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. My aim is to run a pipeline with container can communicate its ports.

Is it possible to implement this issue with 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 .

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. You can then reference it via postgres:5432 with a Docker executor and localhost:5432 with Kubernetes executor.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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