1

I try to run GitLab Runner with docker executor inside LXD container. Have it done half way through but still not functioning properly.

Did anybody happen to have it up and running and could share how to do it ?

mysiar
  • 430
  • 1
  • 5
  • 14
  • some error logs are on gitlab-runner issue https://gitlab.com/gitlab-org/gitlab-runner/issues/3457 – mysiar Jul 30 '18 at 18:30
  • yeah do it all the time.. but your need to delete the container, make a new one make sure its privileged, and then install docker and the runner. – Lawrence Cherone Aug 03 '18 at 05:56
  • I did this and do not work. For someome with same problems, this issue can help. https://github.com/docker/for-linux/issues/103 – lubrum Jan 24 '23 at 03:16
  • I did sort that issue out. Instruction for GitHub runner under the link https://mysiar.github.io/devops/2022/08/14/lxd-container-as-gh-runner.html – mysiar Jan 25 '23 at 10:55

2 Answers2

1

You have to set your docker container to run as privileged. Check the runner config.toml file and set like this:

[runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = true 
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
  [runners.cache]
    Insecure =  false

Also make sure that you have launched your LXC container with the paramaters:

lxc launch --verbose IMAGE CONTAINER_NAME -c security.nesting=true -c security.privileged=true

Plus check the LXC profile to be set like this:

config:
  raw.lxc: |-
    lxc.apparmor.profile = unconfined
    lxc.cgroup.devices.allow = a
    lxc.mount.auto=proc:rw sys:rw
    lxc.cap.drop=
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
  root:
    path: /
    pool: lxd-pa
    type: disk
name: default

In case that even those settings won't change the docker container behavior, try to disable apparmor on the LXC container

Erengroth
  • 11
  • 2
  • Could you explain a bit more about lxc profile config part? that made my gitlab-runner work from inside a lxd container with docker, just want to know more. – lubrum Jan 24 '23 at 11:33
0

Problem sorted out by doing everything by below steps

  1. install lxd container as per https://stgraber.org/2016/04/13/lxd-2-0-docker-in-lxd-712/

  2. install gitlab-runner as per https://docs.gitlab.com/runner/install/linux-repository.html

  3. https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

mysiar
  • 430
  • 1
  • 5
  • 14