[Feature]: Gitlab CI Support
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia esaminando TestcontainersConfiguration e il rilevamento esistente dell’ambiente Docker e la configurazione della connessione. Definisci come la service discovery di GitLab CI, la selezione dell’host Docker, i certificati TLS e il comportamento di fallback debbano integrarsi nella libreria, quindi verifica le configurazioni e gli scenari CI descritti nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Module
No response
Problem
In many GitLab CI pipelines, integration tests that rely on Testcontainers need a running Docker daemon. The typical workaround is:
- Run a docker:dind service in privileged mode
- Mount the host Docker socket into the test container
- Set DOCKER_HOST=unix:///var/run/docker.sock in the test environment
This approach has several pain points:
| Issue | Impact |
|---|---|
| Privileged mode | Requiresprivileged: truein the job, which is disallowed in many shared runners for security reasons. |
| Docker socket exposure | Mounting/var/run/docker.sockcan inadvertently grant the test container full control over the host Docker daemon. |
| Port collisions & networking | The test container must be on the same network namespace as thedocker:dindservice, which is fragile and hard to debug. |
| Resource overhead | Each job starts a full DinD daemon, increasing build time and memory usage. |
| Complex configuration | Users must remember to setDOCKER_HOST,DOCKER_TLS_VERIFY, etc., which is error‑prone. |
A native GitLab CI services integration would eliminate the need for privileged mode, reduce configuration complexity, and improve security:
- Security – Avoid exposing the host Docker socket or running privileged containers.
- Simplicity – A single configuration flag should be sufficient to enable CI‑specific behavior.
- Performance – Reuse the GitLab CI service container’s Docker daemon instead of launching a new DinD instance per job.
- Consistency – Tests run in CI will mirror local development environments that use Testcontainers without any special CI configuration.
Solution
Add a new configuration option to the `Testcontainers` Java library (and analogous options for other languages) that allows the user to specify a GitLab CI service name and network alias. Example (Java):
TestcontainersConfiguration.getInstance()
.withGitLabService("docker:dind", "docker");
Internally, Testcontainers will:
1. Detect that it is running inside a GitLab CI job (e.g., by checking `CI` environment variable).
2. Resolve the service container’s IP address via the GitLab CI network (`docker` alias).
3. Set `DOCKER_HOST=tcp://<service-ip>:2375` (or `2376` if TLS is enabled).
4. Optionally configure TLS certificates if the service exposes them.
Runtime Behavior
- No privileged mode – The job can run without `privileged: true`.
- Automatic network discovery – Testcontainers will query the GitLab CI network for the service alias.
- TLS support – If the GitLab service exposes TLS, the library can automatically pick up the certificates from known paths (`/etc/docker/certs.d/`).
Fallback
If the CI environment is not detected or the service is missing, Testcontainers will fall back to its normal local Docker daemon strategy, preserving backward compatibility.
Benefit
| Category | Impact |
| --- | --- |
| Security | Positive – reduces privileged execution and socket exposure. |
| Performance | Slightly better – reusing the CI service container avoids launching a separate DinD daemon. |
| Developer Experience | Positive – fewer environment variables, clearer CI configuration. |
| Maintenance | Minimal – only a small API addition and a few environment checks. |
| Compatibility | Backward compatible; old jobs continue to work unchanged. |
Alternatives
- Priviledge DinD Runner in Kubernetes
Would you like to help contributing this feature?
Yes
- Lingua principale
- Java
- Stelle
- 8.8k
- Fork
- 2k
- Merge medio
- 5g 21h
- PR unite (30g)
- 15
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testcontainers/testcontainers-java
-
[Bug]: withStartupTimeout() changes the startup timeout of all containers that use the default wait strategyForse già presa @aymenjamaaoui l’ha presa 1 giorno fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
testcontainers/testcontainers-java#12171 ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: Document why singleton containers are required under Spring's test context cachingForse già presa @zakaullah075 l’ha presa 95 giorni fa. Apertatype/enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
testcontainers/testcontainers-java#11967 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under LinuxForse già presa @kdelay l’ha presa 116 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-java#11941 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: DockerDesktopClientProviderStrategy is always applicableForse già presa @seonwooj0810 l’ha presa 165 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
testcontainers/testcontainers-java#11829 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: cleanup document after removing junit4 supportForse già presa @SJvaca30 l’ha presa 173 giorni fa. Apertatype/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
testcontainers/testcontainers-java#11578 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di testcontainers/testcontainers-java
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
pact-foundation/pact-plugins#125 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
opencollab/flexdock#28 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
yegor256/jping#122 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
SAP/ai-sdk-java#1206 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue insight-module
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
sdlc-pro/spring-lens#606 ·
I maintainer di solito rispondono entro 1 giorno