skip to Main Content

I am using docker executor on gitlab runner as an image I am using docker:stable
I am getting this error:

$ docker login gitlab.mydomain.com:5050 -u myusername-p mytoken
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 67.207.67.3:53: no such host
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

Here is my config.toml

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "dev-env"
  url = "https://gitlab.mydomain.com/"
  token = "REDACTED"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

Here is my ci file

deploy-dev:
  stage: deploy
  before_script:
    - apk add make
  script:
    - docker login gitlab.mydomain.com:5050 -u myusnerma -p mytoken
  only:
    - mybranch
  tags:
    - dev

2

Answers


  1. You must add the docker:dind service to your job configuration:

    deploy-dev:
      variables:
        # these values may need to be different if using TLS, k8s, etc.
        # You can alternatively set defaults in your runner config
        DOCKER_TLS_CERTDIR: ""
        DOCKER_HOST: "tcp://docker:2375"
      services:
        - docker:dind
      # ...
    

    For the dind container to work, your runner must allow privileged containers:

      [runners.docker]
        privileged = true
        # ...
    
    Login or Signup to reply.
  2. Beside privileged = true you should also map /var/run/docker.sock inside docker container to /var/run/docker.sock on host. something like this:

    concurrent = 1
    check_interval = 0
    [session_server]
      session_timeout = 1800
    [[runners]]
      name = "my-runner"
      url = "https://gitlab.mydomain.com/"
      token = "GITLAB_RUNNER_TOKEN"
      executor = "docker"
      [runners.custom_build_dir]
      [runners.cache]
        [runners.cache.s3]
        [runners.cache.gcs]
        [runners.cache.azure]
      [runners.docker]
        tls_verify = false
        image = "docker:stable"
        privileged = true
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
        shm_size = 0
    

    More info from techoverflow

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search