2

i'm running 2 gitlab-runner executors:

  1. shell executor (tagged: shell_executor)
  2. docker executor (tagged: docker_executor)

the docker executor runs docker commands just fine, but the shell executor throws: enter image description here

I've already set gitlab-runner to the docker's usergroup. Logging whoami in the CI gives: gitlab-runner. What i'm trying to achive is deploy a docker container on the host's docker service. these are the settings i'm running:

Gitlab-runners'machine: Ubuntu 18.10

.gitlab-ci.yml

stages:
  - build
  - deploy

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs"

before_script:
  - export PATH=$PATH:/usr/bin:/etc/docker

build_staging:
  stage: build
  services:
    - docker:19.03.1-dind
  image: docker:19.03.1
  script:
    - apk add --update --no-cache py2-pip nodejs nodejs-npm yarn
    - yarn install
    - yarn build
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t camoncash .
    - export TAG=$(echo $CI_COMMIT_SHA | cut -c 1-7)
    - docker tag camoncash:latest $CI_REGISTRY/camoncash/camsite/camsite.frontend:$TAG
    - docker tag camoncash:latest $CI_REGISTRY/camoncash/camsite/camsite.frontend:$CI_COMMIT_REF_NAME
    - docker push $CI_REGISTRY/camoncash/camsite/camsite.frontend:$TAG
    - docker push $CI_REGISTRY/camoncash/camsite/camsite.frontend:$CI_COMMIT_REF_NAME
  tags:
    - docker_executor

deploy_staging:
  stage: deploy
  script:
    - export TAG=$(echo $CI_COMMIT_SHA | cut -c 1-7)
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker pull -u $CI_REGISTRY/camoncash/camsite/camsite.frontend:$CI_COMMIT_REF_NAME
    - docker stop camoncash || true && docker rm camoncash || true
    - docker run --name=camoncash -p 3000:3000 -itd $CI_REGISTRY/camoncash/camsite/camsite.frontend:$CI_COMMIT_REF_NAME
  tags:
    - shell_executor

/etc/gitlab-runner/config.toml

[[runners]]
  name = "DockerRunner"
  url = "https://gitlab.com/"
  token = "TOKEN"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/certs/client", "/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

[[runners]]
  name = "ShellRunner"
  url = "https://gitlab.com/"
  token = "TOKEN"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

me atm (╯°□°)╯︵ ┻━┻


UPDATE: I've worked my way around the problem for now by simply installing a gitlab-runner on the host by following here: - https://docs.gitlab.com/runner/install/linux-repository.html and then registering a shell executor to run bash commands directly on the host. Best case scenario would be to have 2 different machines running 1 specific executor. I've also discovered that running 2 different executors (eg: docker and shell) that share the same config.toml creates conflicts.

Paolo
  • 704
  • 9
  • 24
  • `export PATH=$PATH:/usr/bin:/etc/docker` - why do you do that? – KamilCuk Dec 03 '19 at 12:57
  • @KamilCuk to include /usr/bin in path variable, if i do: which docker that's the docker's host path. see this asnwer: https://stackoverflow.com/questions/52535771/gitlab-ci-cd-runner-mvn-command-not-found – Paolo Dec 03 '19 at 13:20
  • did you follow all steps here: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-shell-executor. specifically, did you verify that `gitlab-runner` has access to docker? – Aviad Levy Dec 03 '19 at 17:28
  • @AviadLevy yep, this command: sudo -u gitlab-runner -H docker info, actually outputs (host) docker infos – Paolo Dec 03 '19 at 17:34
  • What is your docker full path? – Aviad Levy Dec 03 '19 at 17:37
  • @AviadLevy 'which docker' outputs: '/usr/bin/docker'. – Paolo Dec 03 '19 at 17:46
  • See [my answer](https://stackoverflow.com/a/69126217/1294349). Making changes in ~/.bash_profile not ~/.bashrc. – Kevin Sep 10 '21 at 02:03

0 Answers0