# Exit code 126 with docker-compose

**URL:** <https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968>\
**Category:** Build Environment\
**Tags:** config, docker\
**Created:** [March 23, 2018, 11:27am UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968 "2018-03-23T11:27:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hoxydev](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hoxydev](https://discuss.circleci.com/u/Hoxydev)\
**Post date:** [March 23, 2018, 11:27am UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/1 "2018-03-23T11:27:47Z")

</div>

Hi guyz,

I’m using circleci and docker-compose configuration. My worlflow is, atm, really easy but running some :  
docker-compose up -d and first test like docker-compose exec php bin/console security:check

My stack is based on [https://api-platform.com/](https://api-platform.com/) , a package including symfony 4 and some nginx conf.

My problem is my build failed with I launch some tools in vendor via docker-compose with an Exit code 126 :  
oci runtime error: exec failed: container\_linux.go:265: starting container process caused “exec: “vendor/bin/phpcs”: stat vendor/bin/phpcs: no such file or directory”

Here’s my circleci config file :

```
version: 2
jobs:
    build:
        docker:
             - image: docker:17.05.0-ce-git
            environment:
                MAX_HEAP_SIZE: 2048m
                HEAP_NEWSIZE: 512m

steps:
    - run:
        name: Install dependencies
        command: |
            apk update && \
                apk upgrade && \
                apk add --no-cache python3 && \
                pip3 install docker-compose

    - checkout

    - setup_remote_docker

    - run:
        name: Configure .env
        command: |
            cp api/.env.dist api/.env

    - run:
        name: Start container and verify it's working
        command: |
            set -x
            docker-compose -f docker-compose.test.yaml up -d && \
            docker-compose exec php bin/console security:check && \
            docker-compose exec php bin/console doctrine:database:create --env=test && \
            docker-compose exec php vendor/bin/phpcs --standard=PSR2 ./src/

```

And here’s my docker-compose file :

```
version: '3'

 services:
    php:
        build:
            context: ./api
            depends_on:
            - db
                env_file:
           - ./api/.env

api:
    build:
        context: ./api
        dockerfile: ./Dockerfile.nginx
    depends_on:
        - php
    ports:
        - "8080:80"

cache-proxy:
    build:
        context: ./api
        dockerfile: ./Dockerfile.varnish
    depends_on:
        - api
    ports:
        - "8081:80"

db:
    # In production, you may want to use a managed database service
    image: postgres:9.6-alpine
    environment:
        - POSTGRES_DB=api
        - POSTGRES_USER=api-platform
        # You should definitely change the password in production
        - POSTGRES_PASSWORD=!ChangeMe!

        # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
        # - ./docker/db/data:/var/lib/postgresql/data:rw
    ports:
        - "5432:5432"

volumes:
    db-data: {}

```

I tried to ssh on the docker machine and i can run the phpcs test with the same command.  
And FYI my build succeeded with the test phpcs

Hope I gave you the maximum of informations to help me find the solutions.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 23, 2018, 12:47pm UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/2 "2018-03-23T12:47:58Z")

</div>

(It looks like your YAML formatting is broken, would you repair it please?)

---

<div class="post-metadata">

**Author:** ![Hoxydev](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hoxydev](https://discuss.circleci.com/u/Hoxydev)\
**Post date:** [March 27, 2018, 3:34pm UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/3 "2018-03-27T15:34:16Z")

</div>

Just did it, ty !

Anyone an idea ?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 27, 2018, 8:33pm UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/4 "2018-03-27T20:33:57Z")

</div>

I can’t see any `composer install` in there - are you sure you’ve installed your PHP dependencies? This looks like a good case for SSHing into your environment after a failed build to debug it - it is probably a Docker/PHP problem rather than a Circle problem.

---

<div class="post-metadata">

**Author:** ![Hoxydev](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hoxydev](https://discuss.circleci.com/u/Hoxydev)\
**Post date:** [March 28, 2018, 1:04pm UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/5 "2018-03-28T13:04:28Z")

</div>

> [@Hoxydev](#):
>
> docker-compose exec php vendor/bin/phpcs --standard=PSR2 ./src/

Humm after more than 150 builds I found the solution and this is the answer :  
docker-compose exec php ./vendor/bin/phpcs --standard=PSR2 ./src/

instead of  
docker-compose exec php vendor/bin/phpcs --standard=PSR2 ./src/

The crazy thing is, when I SSHing on my env the second command line works so I took my time to understand the prob.

Ty you guyz !

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 28, 2018, 2:56pm UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/6 "2018-03-28T14:56:59Z")

</div>

Interesting, I wonder if the system search `PATH` does not have `.` it?

Try `docker-compose exec echo $PATH` to check.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 26, 2018, 2:57pm UTC](https://discuss.circleci.com/t/exit-code-126-with-docker-compose/20968/7 "2018-06-26T14:57:03Z")

</div>

Closed on June 26, 2018, 2:57pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
