Public | Automated Build

Last pushed: 3 months ago
Short Description
PHPUnit is a programmer-oriented testing framework for PHP.
Full Description

PHPUnit Docker Container.

Docker container to install and run PHPUnit.


Installation / Usage

  1. Install the phpunit/phpunit container:

     $ docker pull phpunit/phpunit
  2. Create a phpunit.xml defining your tests suites.

  3. Run PHPUnit through the PHPUnit container:

     $ docker run -v $(pwd):/app --rm phpunit/phpunit run

    or in shorthand add

     $ sudo sh -c "printf \"#!/bin/sh
     export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
     docker run -v $(pwd):/app --rm phpunit/phpunit run \\\$@
     \" > /usr/local/bin/phpunit"
     $ sudo chmod +x /usr/local/bin/phpunit

    and then from host machine just

     $ phpunit --version

To run, test and develop the PHPUnit Dockerfile itself, you must use the source directly:

  1. Download the source:

     $ git clone
  2. Switch to the phpunit-docker directory:

     $ cd phpunit-docker
  3. Build the container:

     $ docker build -t phpunit/phpunit .
  4. Test running the container:

     $ docker run phpunit/phpunit --help

How to generate?

Install associate GEMs

$ gem install bundle
$ bundle

Generate a new version

version=6.0.6 rake version:add

Remove a version

An error in your generation?

version=6.0.6 rake version:remove
Docker Pull Command
Source Repository

Comments (18)
9 months ago

Hi there,

First of all: nice work.

I am trying not to seem offensive: is this approved or supported officially from PHPUnit in any ways, or you just registered the orga on docker hub? Same for phpsec?

9 months ago

Ran my tests recently pulling 'latest' and got 'No code coverage driver is available' - which suggests some kind of xdebug problem. I tried with version 5.1.0 and that seems to work for me.

a year ago

@julienbreux php7-session :)

a year ago

While using pdo connection in test file.I am getting PDOException: SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql' (-2). I have PDO enabled and mysql server host is "mysql". And I am using command " docker run -v $(pwd):/app/tests --rm phpunit/phpunit /app/tests " to run the tests

a year ago

@vesela Do you have more info?

a year ago

@antoniog85, and thanks for your constructive feedback... (the Hub does not notify me)

a year ago

@antoniog85, hi, PHP7 is now supported!

a year ago

I can see that 4 months ago has been asked for the support php7, but I still can't fetch any new tag...

2 years ago

docker run phpunit/phpunit "some test" didnt work for me

2 years ago

@julienbreux I think you have to add the 5.1 tag in order to support php7, don't you?