matt-rock
matt-rock

Reputation: 133

Running Gitlab Runner in Azure Container Instances (ACI)

I would like to run Gitlab-Runner in Azure Container Instances (ACI).

For this I have the docker container gitlab/gitlab-runner running in the Azure ACI.

With the following command I register this runner for my Gitlab server.

gitlab-runner register \
  --non-interactive \
  --run-untagged=true \
  --locked=false \
  --executor "docker" \
  --docker-image docker:latest  \
  --url "https://gitlab.com/" \
  --registration-token "MyTokenYYYYYYYY" \
  --description "my-own-runner" \
  --tag-list "frontend, runner" \
  --docker-volumes /var/run/docker.sock:/var/run/docker.sock

The new runner is also recognized under gitlab. However, when I run a job, I get the following error.

Preparing the "docker" executor
ERROR: Failed to remove network for build
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (docker.go:960:0s)

If I run the Runner with the identical configuration locally on my notebook everything works. How do I get it to work in the Azure ACI?

How can I mount the docker sock in the Azure ACI when registering it?

Many thanks in advance for your help.

Upvotes: 2

Views: 7322

Answers (1)

bpdohall
bpdohall

Reputation: 1051

You're not going to be able to run another docker container inside the container you created in Azure ACI. In order to achieve "docker-in-docker" (dind), the daemon instance (your ACI container in this case) needs to be running in privileged mode which would allow escalated access to the host machine that you are sharing with other ACI users. You can read about this more on Docker hub where it says:

Note: --privileged is required for Docker-in-Docker to function properly, but it should be used with care as it provides full access to the host environment, as explained in the relevant section of the Docker documentation.

The common solution for this is to use an auto-scale group of 0 or more VMs to provide compute resources to your gitlab runners and the containers they spawn.

Upvotes: 1

Related Questions