RedArrow
RedArrow

Reputation: 638

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.

Upvotes: 3

Views: 2229

Answers (1)

Nikolai Prokoschenko
Nikolai Prokoschenko

Reputation: 8765

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.

Upvotes: 2

Related Questions