1
votes

I am using gitlab-runner into a docker container. I'd like to run my builds into a docker container that would embed any depedencies needed. What kind of executor should I use? docker ? If I do that, I run builds on a nested container which is not that recommended I guess.

What is the best practice? thanks

1
If you need to run docker commands inside the build job, you need to use docker in docker, no way around that. - 1615903

1 Answers

1
votes

Here's how I register my runners:

gitlab-runner register -n \
  --url <MY_GITLAB_URL> \
  --registration-token "<MY_TOKEN>" \
  --executor docker \
  --description `hostname` \
  --docker-image "docker:latest" \
  --docker-privileged

And then in my .gitlab-ci.yml:

image: docker:latest
services:
  - docker:dind
script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  - docker build ...
  - docker push ...