title: Gitlab-CI Docker In Docker with Dotnet Testcontainers
body: <p>Good afternoon, folks. I am attempting to run a Gitlab-CI pipeline on a DotNet project that utilizes the nuget package <a href="https://github.com/HofmeisterAn/dotnet-testcontainers" rel="nofollow noreferrer">https://github.com/HofmeisterAn/dotnet-testcontainers</a> to manage docker containers during test execution. Over the past few days, I have tried many different configuration variations, including custom docker images incorporating Dotnet and docker. However, likely due to my lack of knowledge in the CI/CD area, I have yet to get a successful build. The net result is that I cannot get all of the dockers to talk to each other appropriately. I am reaching out for any help in getting this build system setup.</p>
  <p>Thank you.</p>
  <p>Current Configuration:</p>
  <ul>
  <li><p>Docker Desktop (4.5.1) running on windows with Expose daemon enabled in the settings.</p>
  </li>
  <li><p>Gitlab-Runner registered and running locally\</p>
  <pre><code>[[runners]]
    name = &quot;Siegeon Docker Runner&quot;
    url = &quot;https://gitlab.com/&quot;
    token = &quot;withheld&quot;
    executor = &quot;docker&quot;
    [runners.custom_build_dir]
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
      [runners.cache.azure]
    [runners.docker]
      tls_verify = false
      image = &quot;docker:stable&quot;
      privileged = true
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      disable_cache = false
      volumes = [&quot;/cache&quot;]
      shm_size = 0
  </code></pre>
  </li>
  <li><p>Gitlab-ci.yml</p>
  <pre><code>stages:
    - tests
  
  test-with-coverage:
    image: mcr.microsoft.com/dotnet/sdk:6.0
    stage: tests
    services:
      services:
      # DinD service is required for Testcontainers
      - name: docker:dind
      command: [&quot;--tls=false&quot;]
    before_script:
      - docker info
    variables:
      # Instruct Docker not to start over TLS.
      DOCKER_TLS_CERTDIR: &quot;&quot;
      # Improve performance with overlayfs.
      DOCKER_DRIVER: overlay2
      DOCKER_HOST: tcp://docker:2375
      CONFIGURATION: &quot;Debug&quot;
      COVERAGE_FLAG: &quot;XPlat Code Coverage&quot;
      LOGGER_FLAG: &quot;junit;LogFilePath=$CI_PROJECT_DIR/junit/junit-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose&quot;
    script:
      - 'dotnet test
              -c $CONFIGURATION
              -r $CI_PROJECT_DIR/cobertura
              --collect:&quot;$COVERAGE_FLAG&quot;
              --test-adapter-path:.
              --logger:&quot;$LOGGER_FLAG&quot;'
      - cd scripts
      - chmod +x print-dotnet-coverage.sh
      - ./print-dotnet-coverage.sh $CI_PROJECT_DIR/cobertura
    coverage: /TOTAL_COVERAGE=(\d+.\d+)/
    artifacts:
      paths:
        - $CI_PROJECT_DIR/cobertura/*/coverage.cobertura.xml
        - $CI_PROJECT_DIR/junit/junit-test-result.xml
      reports:
        cobertura:
          - $CI_PROJECT_DIR/cobertura/*/coverage.cobertura.xml
        junit:
          - $CI_PROJECT_DIR/junit/junit-test-result.xml
  </code></pre>
  </li>
  </ul>
  <p>Gitlab logs</p>
  <pre><code>```
  Running with gitlab-runner 14.7.0 (98daeee0)
    on Siegeon Docker Runner TdwgDJWA
  Preparing the &quot;docker&quot; executor
  00:50
  Using Docker executor with image mcr.microsoft.com/dotnet/sdk:6.0 ...
  Starting service docker:dind ...
  Pulling docker image docker:dind ...
  Using docker image sha256:1a42336ff683d7dadd320ea6fe9d93a5b101474346302d23f96c9b4546cb414d 
  for docker:dind with digest docker@sha256:6f2ae4a5fd85ccf85cdd829057a34ace894d25d544e5e4d9f2e7109297fedf8d ...
  Waiting for services to be up and running...
  *** WARNING: Service runner-tdwgdjwa-project-33678908-concurrent-0-82673b37ef5d9ae1-docker-0 probably didn't start properly.
  Health check error:
  service &quot;runner-tdwgdjwa-project-33678908-concurrent-0-82673b37ef5d9ae1-docker-0-wait-for-service&quot; timeout
  Health check container logs:
  Service container logs:
  2022-03-02T17:34:46.439281600Z time=&quot;2022-03-02T17:34:46.438975100Z&quot; level=info msg=&quot;Starting up&quot;
  2022-03-02T17:34:46.440522500Z time=&quot;2022-03-02T17:34:46.440396800Z&quot; level=warning msg=&quot;could not change group 
  /var/run/docker.sock to docker: group docker not found&quot;
  ```
  </code></pre>