title: Gitlab CI - runner - how to config multiple docker executors on the same server
body: <p>I'm trying to setup on the same server (D.O. cloud) two different envs based on docker, once for staging and once for production.</p>
  <p>The two envs are off course isolated and the deployment is assigned to gitlab ci/cd pipeline.</p>
  <p>My goal is to run on the same server two different ci pipeline, once for <strong>staging</strong> and once for <strong>production</strong>.</p>
  <p>At the beginning my conf was a single runner with docker executor but I notified that just one single env remained live after a pipeline execution (no matter what if it's from staging or production tag).</p>
  <p>As I mentioned my goal is to have live both envs, then I thought to register a new runner in order to map one runner for one env (and tag).</p>
  <p>Both runners with docker executor.</p>
  <p>Here is my last configurations</p>
  <p>.gitlab.ci.yml</p>
  <pre><code>image: tmaier/docker-compose:latest
  
  stages:
    - deploy-on-staging
    - deploy-on-prod
  
  services:
    - docker:dind
    
  
  before_script:
    - docker info
    - docker-compose --version
  
  #job runs automatically for tags:staging
  step-staging:
    stage: deploy-on-staging
    environment:
      name: staging  # must match the vars env 
      url: staging.mysite.com$STAGING_HTTP_PORT
    only:
      - staging
    tags:
      - staging
    script:
      - docker-compose -f docker/remote/docker-compose.yml -f docker/remote/docker-compose.staging.yml up -d 
    after_script:
      - docker exec -i mysql_staging sh -c 'exec mysql -uroot -p&quot;$MYSQL_ROOT_PASSWORD&quot; &lt; /docker-entrypoint-initdb.d/db.sql'
      - docker exec mysql_staging sh -c 'exec mysql -u gu -p&quot;$MYSQL_PASSWORD&quot; -D dbname &lt; /opt/somequeries.sql'
  
  #job runs automatically for tags:production
  step-prod:
    stage: deploy-on-prod
    environment:
      name: production # must match the vars env  
      url: mysite.com
    only:
      - master
    tags:
      - production
    script:
      - docker-compose -f docker/remote/docker-compose.yml -f docker/remote/docker-compose.override.yml up -d
    after_script:
      - docker exec -i mysql_prod sh -c 'exec mysql -uroot -p&quot;$MYSQL_ROOT_PASSWORD&quot; &lt; /docker-entrypoint-initdb.d/db.sql'
      - docker exec mysql_prod sh -c 'exec mysql -u gu -p&quot;$MYSQL_PASSWORD&quot; -D dbname &lt; /opt/somequeries.sql'
    when: manual
  </code></pre>
  <p>config.toml</p>
  <pre><code>concurrent = 1
  check_interval = 0
  
  [session_server]
    session_timeout = 1800
  
  [[runners]]
    name = &quot;runner&quot;
    url = &quot;https://gitlab.com&quot;
    token = &quot;xxxxxxxxxxxxxxxxxxxx&quot;
    executor = &quot;docker&quot;
    [runners.custom_build_dir]
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
    [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;/var/run/docker.sock:/var/run/docker.sock&quot;, &quot;/cache&quot;, &quot;/builds:/builds&quot;]
      shm_size = 0
      memory = &quot;128m&quot;
      memory_swap = &quot;256m&quot;
      memory_reservation = &quot;128m&quot;
  
  [[runners]]
    name = &quot;staging_runner&quot;
    url = &quot;https://gitlab.com&quot;
    token = &quot;xxxxxxxxxxxxxxxxxxxx&quot;
    executor = &quot;docker&quot;
    [runners.custom_build_dir]
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
    [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;/var/run/docker.sock:/var/run/docker.sock&quot;, &quot;/cache&quot;, &quot;/builds:/builds&quot;]
      shm_size = 0
      memory = &quot;128m&quot;
      memory_swap = &quot;256m&quot;
      memory_reservation = &quot;128m&quot;
  </code></pre>
  <p>I have not reached my goal yet. Plus <strong>now the staging pipeline give me back an error like this</strong></p>
  <pre><code>error during connect: Get [http://docker:2378/v1.40/containers/mysql_staging/json:](http://docker:2378/v1.40/containers/mysql_staging/json:) dial tcp: lookup docker on XX.XXX.XX.X:53: no such host
  </code></pre>
  <p>Is my design correct to reach my goal?</p>
  <p>If yes, do I have any misconfiguration?</p>
  <p>Thank you in advance for your help.</p>