Exit code 126 with docker-compose

docker
config

#1

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/ , 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.


#2

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


#3

Just did it, ty !

Anyone an idea ?


#4

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.


#5

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 !


#6

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

Try docker-compose exec echo $PATH to check.


#7

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