Public | Automated Build

Last pushed: 2 years ago
Short Description
Docker image for running tox with multiple Python interpreters and versions.
Full Description


Available on Docker Hub as themattrix/tox.

This image is intended for running tox with
Python 2.6, 2.7, 3.3, 3.4, 3.5, PyPy, and PyPy3.
Its goal is to make testing your code against multiple Python versions quick and easy.
The image contains several ONBUILD commands for initializing the tox environments with
your project's requirements.txt files.


The Dockerfile contains the following ONBUILD commands:

ONBUILD COPY install-prereqs*.sh requirements*.txt tox.ini /app/
ONBUILD RUN bash -c " \
    if [ -f '/app/' ]; then \
        bash /app/; \
    fi && \
    if [ $SKIP_TOX == false ]; then \
        TOXBUILD=true tox; \

This means your project must contain a tox.ini file.

You can also optionally include an script for installing
prerequisites of the project requirements.

To avoid the tox environments being rebuilt every time you want to test your code,
tox is run twice - first with the TOXBUILD environment variable set to true,
and second without it being set:

  1. $ TOXBUILD=true tox

    Executed during the build phase to initialize all of the environments. It is
    expected not to install your code nor run your tests; it should only
    install the requirements which your project needs to be tested.

    This step can be skipped by specifying --build-arg SKIP_TOX=true in the build phase.

  2. $ tox

    Executed during the run phase to test your code.

When your requirements or tox configuration changes, both steps are run.
When your code changes, only the second step is run, saving valuable time.
This also ensures that your code is always tested in a completely clean

Example tox.ini supporting the TOXBUILD environment variable:

envlist = py26,py27,py33,py34,py35,pypy,pypy3
skipsdist = {env:TOXBUILD:false}

passenv = LANG
whitelist_externals = true
deps =
commands = {env:TOXBUILD:./ --static-analysis}

For a full example, see the python-pypi-template project, which uses this image.

Docker Pull Command
Source Repository