title: docker-compose throws error with gitlab-ci
body: <p>I try to use <strong>Gitlab CI</strong> with <strong>docker-compose</strong> but I always get this error :</p>
  
  <pre><code>$ docker-compose up -d --build
  Creating network "backoffice_default" with the default driver
  Building php
  Creating backoffice_database_1 ... 
  Creating backoffice_database_1 ... done
  Creating backoffice_php_1 ... 
  Creating backoffice_php_1 ... done
  
  $ docker-compose exec php composer -v
  Traceback (most recent call last):
    File "bin/docker-compose", line 6, in &lt;module&gt;
    File "compose/cli/main.py", line 68, in main
    File "compose/cli/main.py", line 121, in perform_command
    File "compose/cli/main.py", line 464, in exec_command
    File "site-packages/dockerpty/pty.py", line 338, in start
    File "site-packages/dockerpty/io.py", line 32, in set_blocking
  ValueError: file descriptor cannot be a negative integer (-1)
  Failed to execute script docker-compose
  </code></pre>
  
  <p>I use docker with <code>shell</code> runner, as follows : </p>
  
  <pre><code>[[runners]]
    name = "direct runner"
    url = MY_GITLAB_URL
    token = REPO_GITLAB_TOKEN
    executor = "shell"
    [runners.cache]
  </code></pre>
  
  <p>Here's my <code>docker-compose.yml</code> file : </p>
  
  <pre><code>version: '2'
  
  services:
  
    database:
      image: mysql:latest
      environment:
        MYSQL_DATABASE: database
        MYSQL_ROOT_PASSWORD: mysql_strong_password
        MYSQL_USER: database
        MYSQL_PASSWORD: mysql_strong_password
  
    php:
      build: ./app/docker
      tty: true
      volumes:
        - ./app/docker/php.ini:/usr/local/etc/php/conf.d/custom.ini
        - ./:/var/www/symfony
      links:
        - database
  </code></pre>
  
  <p>And here's my <code>.gitlab-ci.yml</code></p>
  
  <pre><code>stages:
  - build
  - cleanup_build
  - test
  - deploy
  - cleanup
  
  before_script:
  - docker info
  
  build:
    stage: build
    script:
    - docker-compose up -d --build
    - docker-compose exec php composer -v
    - docker-compose exec php composer install
    - docker-compose exec php php bin/console doctrine:schema:create --dump-sql --force
    - docker-compose exec php php bin/console doctrine:fixtures:load -n
  
  cleanup_build:
    stage: cleanup_build
    script:
    - docker-compose config
    - docker-compose ps
    - docker-compose logs php
    - docker-compose logs database
    - exit 1
    when: on_failure
  
  phpunit:
    stage: test
    script:
    - docker-compose exec -T php phpunit -c .
  
  deploy:
    stage: deploy
    script:
    - echo "deploy to staging server"
  
  cleanup:
    stage: cleanup
    script:
    - docker-compose down
  </code></pre>
  
  <p>Do you guys have any idea on how to resolve this ?
  Because I tried directly from shell using <code>gitlab-runner</code> user and executing the same cmds i didn't have any error. I tried to run the <code>docker-compose exec</code> with the <code>-T</code> flag and there is another error : <code>ERROR: Job failed: exit status 1</code> with no additionnal message</p>