I've also tried doing the same with Sqlite, using the below command, however its failing with PDO driver not found.
php -n -d extension=pdo_sqlite.so vendor/bin/phpunit
I haven't had a chance to look into this, my guess is that something isn't configured in config/database.php settings.
The image I'm using is a custom image fromphp:7.2.9-fpm-alpine3.8, below is the Dockerfile.
FROM php:7.2.9-fpm-alpine3.8
RUN apk add --no-cache \
$PHPIZE_DEPS \
openssh \
zlib-dev \
&& docker-php-ext-install pdo pdo_mysql \
&& pecl install redis && docker-php-ext-enable redis \
&& pecl install xdebug-2.6.0 && docker-php-ext-enable xdebug \
&& { \
echo 'xdebug.remote_autostart=1'; \
echo 'xdebug.remote_enable=1'; \
echo 'xdebug.remote_host=host.docker.internal'; \
echo 'xdebug.remote_port=9000'; \
echo 'xdebug.idekey=PHPSTORM'; \
} >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
--version=1.7.2 \
--install-dir=/usr/bin --filename=composer \
&& php -r "unlink('composer-setup.php');"