title: Gitlab CI + DinD + MySQL services permission issue
body: <p>I created two GitLab jobs:</p>
  <ul>
  <li>Test unit (using a PHP registered docker on GitLab)</li>
  <li>Sonar (using docker service to run &quot;Letsdeal/docker-sonar-scanner&quot;)</li>
  </ul>
  <p>I use the following gitlab-ci-multi-runner configuration:</p>
  <pre><code>concurrent = 1
  check_interval = 0
  
  [[runners]]
    name = &quot;name-ci&quot;
    url = &quot;https://uri/ci&quot;
    token = &quot;token&quot;
    executor = &quot;docker&quot;
    [runners.docker]
      tls_verify = false
      image = &quot;docker:latest&quot;
      privileged = true
      disable_cache = false
      volumes = [&quot;/cache&quot;]
      shm_size = 0
    [runners.cache]
  </code></pre>
  <p>The test unit job works correctly, but the Sonar job failed with the following messages:</p>
  <pre><code>service runner-f66e3b66-project-227-concurrent-0-docker-wait-for-service did timeout
  
  2017-07-05T16:13:18.543802416Z mount: mounting none on /sys/kernel/security failed: Permission denied
  2017-07-05T16:13:18.543846406Z Could not mount /sys/kernel/security.
  2017-07-05T16:13:18.543855189Z AppArmor detection and --privileged mode might break.
  2017-07-05T16:13:18.543861712Z mount: mounting none on /tmp failed: Permission denied
  </code></pre>
  <p>When I change the configuration param 'privileged' of 'runner.docker' to false, the Sonar job works but Test Unit fails:</p>
  <pre><code>service runner-f66e3b66-project-227-concurrent-0-mysql-wait-for-service did timeout
  
  2017-07-05T15:08:49.178114891Z 
  2017-07-05T15:08:49.178257497Z ERROR: mysqld failed while attempting to check config
  2017-07-05T15:08:49.178266378Z command was: &quot;mysqld --verbose --help&quot;
  2017-07-05T15:08:49.178271850Z 
  2017-07-05T15:08:49.178276837Z mysqld: error while loading shared libraries: libpthread.so.0: cannot open shared object file: Permission denied
  </code></pre>
  <p>The param &quot;privileged&quot; has to be true to be able to use docker in docker. But I don't understand why it makes permission broken for services like MySQL.</p>
  <p>Here is my gitlab-ci file:</p>
  <pre><code>stage :
    - test-unit
    - analyse
  
  .php_job_template: &amp;php_job_template
    image: custom_docker_image
    before_script:
      - eval $(ssh-agent -s) &amp;&amp; ssh-add &lt;(echo &quot;$SSH_PRIVATE_KEY&quot;)
      - mkdir -p ~/.ssh &amp;&amp; echo -e &quot;Host *\n\tStrictHostKeyChecking no\n\n&quot; &gt; ~/.ssh/config
    services :
      - mysql
    variables:
      MYSQL_DATABASE: blabla
      MYSQL_USER: blabla
      MYSQL_PASSWORD: blabla
      MYSQL_ROOT_PASSWORD: blabla
  
  test_phpunit_dev:
    &lt;&lt;: *php_job_template
    stage: test-unit
    script:
      - mysql -h mysql -u blabla -pblabla &lt;&lt;&lt; &quot;SET GLOBAL sql_mode = '';&quot;
      - php composer.phar install -q
      - php vendor/bin/phpunit -c tests/phpunit.xml
  
  sonar:
    stage: analyse
    image: docker:1.12.6
    services:
      - docker:dind
    script:
      - docker run --rm -v `pwd`:/build -w /build letsdeal/sonar-scanner:2.7 scan -e
  </code></pre>
  <p>How do I fix this?</p>