Answers: <p>Don't quote the command you're trying to run, just do:</p>
  
  <pre><code>docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php php ./vendor/bin/phpunit
  </code></pre>
  
  <p>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. </p>
  
  <p>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. </p>
  
  <p>The Dockerfile equivalent is:</p>
  
  <pre><code>ENTRYPOINT ["/init","parameter1","parameter2","parameter3"]
  </code></pre>
  
  <p>If it still doesn't work, check the parent Dockerfiles for the location of "php" </p>
  
  <pre><code>docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php /usr/local/bin/php ./vendor/bin/phpunit
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-05-10T15:22:34.067Z
Answers: 2019-05-10T15:22:34.067Z
Answers: Dagelf
Body: <p>i want to run a specific version of phpUnit WITHIN a docker container. This container will use a specific version of php. i.e</p>
  
  <p>php:5.6-apache</p>
  
  <p>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:</p>
  
  <blockquote>
    <p>"require-dev": { "phpunit/phpunit": "^5.0" }</p>
  </blockquote>
  
  <p>This is my docker run command to run the test on my testdev container:</p>
  
  <pre><code>docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php "php ./vendor/bin/phpunit"
  </code></pre>
  
  <p>This returns the error:</p>
  
  <pre><code>exec: fatal: unable to exec php ./vendor/bin/phpunit: No such file or directory
  </code></pre>
  
  <p>i am unclear why it says this because te vendor directory is at the root of my site directory.</p>
  
  <p>this is my dockerfile</p>
  
  <pre><code>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"]
  </code></pre>
  
  <p>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.</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-03-19T09:10:26.590Z
Comments: Check your logs, but you're copying data into your container at the point of your mount, that sounds likely to cause problem, a full log with the directory where you're executing the command would help spotting the problem.
Comments: Tensibai
Comments: CC BY-SA 4.0
Comments: 2019-03-19T15:10:32.520Z
Comments: @Tensibai hi mate. thanks for responding. i am still new to docker. so i am a bit confused with your explanation. could you please explain in more detail what you mean, possibly give examples. thank you
Comments: Paul Kendal
Comments: CC BY-SA 4.0
Comments: 2019-03-19T15:34:24.043Z
Comments: What I mean is: Copy and Paste the full output after your docker command in your question, [edit] it, without it we can't help or explain what is going wrong without divination.
Comments: Tensibai
Tags: <docker><docker-compose><dockerfile>
Title: running a phpUnit test within a docker container
UserDisplayName: Paul Kendal
ThreadText: # running a phpUnit test within a docker container
  
  (Asked by: username_0 on 2019-03-19)
  
  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 && apt-get install -y \
      libldap2-dev \
      git \
      --no-install-recommends \
      && rm -r /var/lib/apt/lists/* \
      && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
      && docker-php-ext-install ldap \
      && docker-php-ext-install mysqli pdo pdo_mysql
  
  #install xdebug 
  RUN git clone https://github.com/xdebug/xdebug.git \
      && cd xdebug \
      && git checkout tags/XDEBUG_2_5_5 \
      && phpize \
      && ./configure --enable-xdebug \
      && make \
      && 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.
  
  **Tags:** docker, docker-compose, dockerfile
  
  > **Comments:**
  > **username_1**: Check your logs, but you're copying data into your container at the point of your mount, that sounds likely to cause problem, a full log with the directory where you're executing the command would help spotting the problem.  
  > **username_0**: @username_1 hi mate. thanks for responding. i am still new to docker. so i am a bit confused with your explanation. could you please explain in more detail what you mean, possibly give examples. thank you  
  > **username_1**: What I mean is: Copy and Paste the full output after your docker command in your question, [edit] it, without it we can't help or explain what is going wrong without divination.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-05-10. Score: 1
  
  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
  
  ```
  
  
  ---
  
  