running a phpUnit test within a docker container i want to run a specific version of phpUnit WITHIN a docker container. This container will use a specific version of php. i.e

php:5.6-apache

Its a lareval application. i have install phpunit via composer on the hostfiles and then used the volume command to transfer this to the container.
my composer.json file has following entry:


  "require-dev": { "phpunit/phpunit": "^5.0" }


This is my docker run command to run the test on my testdev container:

docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php "php ./vendor/bin/phpunit"


This returns the error:

exec: fatal: unable to exec php ./vendor/bin/phpunit: No such file or directory


i am unclear why it says this because te vendor directory is at the root of my site directory.

this is my dockerfile

FROM php:5.6-apache

ENV S6_OVERLAY_VERSION 1.11.0.1

RUN apt-get update &amp;&amp; apt-get install -y \
    libldap2-dev \
    git \
    --no-install-recommends \
    &amp;&amp; rm -r /var/lib/apt/lists/* \
    &amp;&amp; docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
    &amp;&amp; docker-php-ext-install ldap \
    &amp;&amp; docker-php-ext-install mysqli pdo pdo_mysql

#install xdebug 
RUN git clone https://github.com/xdebug/xdebug.git \
    &amp;&amp; cd xdebug \
    &amp;&amp; git checkout tags/XDEBUG_2_5_5 \
    &amp;&amp; phpize \
    &amp;&amp; ./configure --enable-xdebug \
    &amp;&amp; make \
    &amp;&amp; make install


RUN a2enmod rewrite

COPY ./docker/rootfs /
COPY . /app

WORKDIR /app

ENTRYPOINT ["/init"]


I guess the real question is this: what is the correct way to run a phpUnit test within a docker container so that its subject to the php version within that container.
Don't quote the command you're trying to run, just do:

docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php php ./vendor/bin/phpunit


Your image is looking for a file called "php ./vendor/bin/phpunit" instead of looking for "php" and passing everything else on the line to it. 

This is the real reason docker requires all your parameters before the image, because the parameter after the image is the command and everything after it is parameters to that command - don't quote everything. 

The Dockerfile equivalent is:

ENTRYPOINT ["/init","parameter1","parameter2","parameter3"]


If it still doesn't work, check the parent Dockerfiles for the location of "php" 

docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php /usr/local/bin/php ./vendor/bin/phpunit