Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job failed - gitlab-ci #21

Closed
programmingworld1 opened this issue Sep 19, 2019 · 9 comments
Closed

Job failed - gitlab-ci #21

programmingworld1 opened this issue Sep 19, 2019 · 9 comments

Comments

@programmingworld1
Copy link

programmingworld1 commented Sep 19, 2019

Hi, I copied and paste the code into the gitlab-ci.yml file but it says that the job has failed.. How can I fix this, I have been struggling with gitlab-ci in combination with my project that is docker-composed based.. Please help me out.

Pulling docker image tmaier/docker-compose:latest ...
Using docker image sha256:7f72c82000a4b80146e835ff4678fbf64cd50ea5549ff411a84fbea25d12027e for tmaier/docker-compose:latest ...
Running on runner-MY6PvAGd-project-12-concurrent-0 via ovs-transip-gitlab-runner...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/murat.yilmaz/devicemanagerapp/.git/
Created fresh repository.
From https://devops.ovsoftware.com/murat.yilmaz/devicemanagerapp
 [new branch]      master     -> origin/master
Checking out b1ac0c93 as master...
Skipping Git submodules setup
$ docker info
Client:
 Debug Mode: false
Server:
ERROR: error during connect: Get http://docker:2375/v1.40/info: dial tcp: lookup docker on 195.8.195.8:53: no such host
errors pretty printing info
ERROR: Job failed: exit code 1
@desm
Copy link

desm commented Oct 3, 2019

Maybe try editing your GitLab runner's config file (config.toml) by changing "volumes = ["/cache"]" to "volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]" and see if that helps?

@desm
Copy link

desm commented Oct 3, 2019

I forgot to specify that the approach I suggested just now is based on this: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-socket-binding

@tmaier
Copy link
Owner

tmaier commented Jan 13, 2020

Can you please provide more information: Are you using gitlab.com? Are you using your own cloud-runner? How is it set up? How is docker configured here?

@abmruman
Copy link

@programmingworld1 , @tmaier This can happen while using newer docker images like version 19.03. Although this issue is a bit old, but the problem persists till today.

I faced the issue recently and turns out there is a known "solution" or workaround however.
Refer to this Release Note, if you want more details.

Reason:

As of version 19.03, docker:dind will automatically generate TLS certificates and require using them for communication. This is from Docker's official documentation:

Solution/workarounds:

According to the Release Note, there are 2 workarounds:

  1. Explicitly turn off TLS.
  2. Configure GitLab Runner to use TLS.

Turn off TLS

If you cannot or do not want to edit the config.toml, like in a gitlab shared runner:

.gitlab-ci.yml:

image: tmaier/docker-compose:19.03

variables:
  DOCKER_TLS_CERTDIR: ""

Configure TLS

If you are running jobs on a runner that you have write access to the config.toml file (and you know what you are doing):

config.toml:

...

[[runners]]
  name = "My Docker Runner"
  url = "http://gitlab.com"
  token = ""
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    ## Changes here ##
    privileged = true  ## may not be necessary, default is false
    volumes = ["/certs/client", "/cache"]  ## adds volume "/certs/client"
    shm_size = 0

...

.gitlab-ci.yml:

image: tmaier/docker-compose:19.03

variables:
  # Create the certificates inside this directory for both the server
  # and client. The certificates used by the client will be created in
  # /certs/client so we only need to share this directory with the
  # volume mount in `config.toml`.
  DOCKER_TLS_CERTDIR: "/certs"`

@tmaier
Copy link
Owner

tmaier commented Apr 12, 2020

Thank you, @abmruman. I hope it solved the issue for @programmingworld1. I am closing this issue

@tmaier tmaier closed this as completed Apr 12, 2020
@brice-gros
Copy link

privileged = true appeared to be necessary on my case
Thank you very much @abmruman

@abmruman
Copy link

@brice-gros , I came to learn that if you want to use docker-in-docker service, you need a privileged runner.

@Michael1024-CJX
Copy link

I tried configuring TLS, but it didn't work. Problem solved by configuring

[runners.docker]
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]

@lwiechec
Copy link

lwiechec commented Dec 2, 2022

thanks a lot - @Michael1024-CJX method helped me too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants