How to run test container in git lab shared runner without security concerns? #10806
Replies: 1 comment
-
On GitLab shared runners you can’t rely on privileged DinD for Testcontainers. That’s a runner policy / Docker constraint, not a Testcontainers feature gap. Use one of these safe patterns: Options that work without --privileged:
Store the certs as masked CI variables. Job stays unprivileged; all containers run on the remote host. About the docs link: The current GitLab CI guide shows DinD for simplicity. For shared runners with security constraints, add an alternative section showing:
Not recommended: Disabling Ryuk or trying to mirror the Docker socket inside an unprivileged DinD job. You’ll lose cleanup guarantees and still face LSM restrictions. Bottom line: This isn’t a feature “coming later”—it’s about choosing a Docker provider that fits shared-runner security. Remote Docker, a private runner, or Testcontainers Cloud are the practical, secure paths today. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to run test container in git lab shared runner without security concerns?
primarily because it often requires running containers in --privileged mode, which grants them root-level access to the host. This undermines container isolation and can expose the host system to attacks. DinD can interfere with Linux Security Modules
What changes need to be done here https://java.testcontainers.org/supported_docker_environment/continuous_integration/gitlab_ci/
when running via a shared runner with security concerns. Is this a feature which will be coming later.
Beta Was this translation helpful? Give feedback.
All reactions