3

I am trying to get a docker compose file to run a local gitlab + gitlab-runner and it seems I have a naming / network issue.

What IS working :

  • I have gitlab and the gitlab runner up and running
  • gitlab works as a remote for local repos, cloning, pushing & so on.
  • gitlab-runner works fine as a runner for my projects on other gitlab servers (tested on gitlab.com)
  • I can register the runner for a project in my gitlab container, view the config, trigger a job (the docker executor starts and gets the image to run the environment)

What IS NOT working :

  • The job fails when trying to get source from the project repository with the following error message (the repository url it tries to access is correct)

fatal: unable to access 'http://gitlab:8081/cours/pipelinediscover.git/': Failed to connect to gitlab port 8081 after 131012 ms: Couldn't connect to server

Here are

  1. My current docker compose yml
version: '3.6'
services:
  gitlab:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    container_name: gitlab
    hostname: 'gitlab'
    environment:
      GITLAB_OMNIBUS_CONFIG: 
        external_url 'http://gitlab:8081'
        # Add any other gitlab.rb configuration here, each on its own line
    ports:
      - '8081:8081'
      - '4443:443'
      - '2222:22'
    volumes:
      - './config:/etc/gitlab'
      - './logs:/var/log/gitlab'
      - './data:/var/opt/gitlab'
    shm_size: '1024m'
  runner:
    image: 'gitlab/gitlab-runner:latest'
    restart: always
    volumes:
      - './gitlab-runner/config:/etc/gitlab-runner'
      - '/var/run/docker.sock:/var/run/docker.sock'
    container_name: gitlab-runner

n.b I had to edit my host /etc/hosts file to be able to access the interface at gitlab:8081 and not localhost:8081 that may not be ideal but if gitlab is configured with external_url at "localhost:8081" then the gitlab-runner cannot interface with it at all. There might be some sweet spot in both docker & gitlab config I missed for domain/network naming.

  1. The runner toml config :
concurrent = 5
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "05f411d789cb"
  url = "http://gitlab:8081/"
  id = 6
  token = "9HXz2_XQzLCpqPiTqDUZ"
  token_obtained_at = 2023-03-31T07:09:00Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

1 Answer 1

1

It looks like you haven't configured networking between the services in your compose file.

If you configure both services to use the same network (or specify depends_on: [gitlab] for the runner service) the name should be resolvable by default and the connection will be allowed.

services:
  gitlab:
   networks:
     - appnet
  # ...
  runner:
    # ...
    networks:
      - appnet

networks:
  appnet:

Or

services:
  # ...
  runner:
    depends_on: [gitlab]
    # ...
Sign up to request clarification or add additional context in comments.

1 Comment

As obvious an overlook on my part it was, clarifying the networking between the two services with either "links" or a named network didn't solved my issue. Same error exactly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.