Search code examples
dockergitlab-cigitlab-ci-runnerwindows-subsystem-for-linuxrunner

gitlab runner - network_mode = "host"


I want to setup CI/CD in GitLab. So i installed docker and the gitlab-runner on linux, created a config for a runner and started everything. So far so good.

The runner works, and docker works.

But i am using the linux subsystem from windows, so i need to run the docker container with parameter "--network host" otherwise they not gonna work.

So right now i try to configure the gitlab-runner to use the host network via the "network_mode" parameter. But it does not work. I get the same error as if i would run a docker container directly and without the "--network host".

The error:

WARNING: Preparation failed: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "process_linux.go:368: container init caused \"process_linux.go:351: running prestart hook 0 caused \\"error running hook: exit status 1, stdout: , stderr: time=\\\\"2019-04-12T18:42:33+02:00\\\\" level=fatal msg=\\\\"failed to add interface vethfc7c8d1 to sandbox: failed to get link by name \\\\\\\\"vethfc7c8d1\\\\\\\\": Link not found\\\\" \\n\\"\"" (executor_docker.go:423:16s) job=123project=123 runner=123

This is my config:

concurrent = 1
check_interval = 0

[session_server]
session_timeout = 1800

[[runners]]
    name = "MyHostName"
    url = "https://my.gitlab.url/"
    token = "SoMeFaNcYcOdE-e"
    executor = "docker"
    [runners.docker]
        tls_verify = false
        image = "beevelop/ionic:latest"
        privileged = true
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache"]
        shm_size = 0
        network_mode = "host"
        [runners.cache]
        [runners.cache.s3]
        [runners.cache.gcs]

My question is how do i force the gitlab runner to create the containers to use the host network like with the docker parameter: "--network host"


Solution

  • I was unable to solve the problem directly, but i found an alternative way which is a lot better.

    I configured the GitLab Container Registry of the repository to upload and white list a custom docker image and then enabled the Shared Runners of my company. The custom image i uploaded was created via a Dockerfile using docker for windows, avoiding the struggle of the buggy docker in the linux subsystem of windows. Now i can execute my CI pipeline flawlessly and have full control over the used image and do not have to keep my local machine running.