I'd like to use a GitLab Runner in a docker container as explained in the doc mostly to easily deploy it to another machine. I'm wondering how to use it to safely run the CI/CD jobs that GitLab sends to the runner.
GitLab Runner documentation warns that using shell as an executor is unsafe, because all code runs with the GitLab runner user permissions and can thus access everything that user has access to on the host machine.
Is it safe, however, to use a shell executor with a GitLab Runner running in a docker container? My intuition is that all security concerns fall back to the docker container: if it's not running with --privileged
mode and the system resources are not exposed via a binding to the container, the job can't be any threat to the host. Multiple jobs run by the GitLab Runner can still access one-another's data, but the host system is out of reach. Are there other concerns I should be aware of?
Alternatively, is there a safe way to run GitLab runner in a docker container and have the ci/cd jobs to build, test and deploy also run in their own docker container? The Docker-in-Docker approach seems to do it but requires the GitLab Runner container to run with the --priviledged
mode, which I'd rather avoid, mostly out of ignorance of the security issues that may come with it.