How can I run my phpunit tests while travis builds my docker containers?

  docker, mariadb, phpunit, travis-ci

I develop a symfony5 project in docker containers, which uses mariadb as project db and another one as test db. I would like to run my unit tests with every deployment so I can check the minimal code coverage.

All tutorials I find seem to use no docker container like this one: and I cannot work out to get a test db running on travis.

Checks like phpCodesniffer or phpstan are no problem and I got them working with

    - docker run $IMAGE:$TRAVIS_COMMIT /bin/sh -c "bin/phpcs"
    - docker run $IMAGE:$TRAVIS_COMMIT /bin/sh -c "bin/phpstan analyze -c phpstan.neon.dist --memory-limit=1G"

Of course they need no database.

    - docker run $IMAGE:$TRAVIS_COMMIT /bin/sh -c "bin/console do:mi:mi -n"
    - docker run $IMAGE:$TRAVIS_COMMIT /bin/sh -c "bin/console do:fi:lo -n"
    - docker run $IMAGE:$TRAVIS_COMMIT /bin/sh -c "bin/phpunit --configuration=phpunit.xml.dist"

complains unsurprisingly, that it doesn’t find a database.

How can I setup da test db using either mysql or mariadb (no sqllite!) to get my tests running?

Source: Docker Questions