I’m using Docker compose to spin up an integration test environment of a PHP application, database, etc. Then I execute the tests in the container of my PHP application. I use DOCKER_HOST=ssh://test.server
to run the tests remote (from my Mac).
On my Mac I run
DOCKER_HOST=ssh://test.server docker-compose up -d
DOCKER_HOST=ssh://test.server docker exec php-container \
./phpunit --configuration config.xml
This is working fine, but slower than a SSH tunnel as suggested by @mottati in this comment. Therefore, I run
- on my Mac
ssh -L 8888:localhost:8888 test.server
- on
test.server
socat TCP-LISTEN:8888,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock
- on my Mac
DOCKER_HOST=tcp://localhost:8888 docker-compose up -d DOCKER_HOST=tcp://localhost:8888 docker exec php-container \ ./phpunit --configuration config.xml
However, while
DOCKER_HOST=ssh://test.server docker exec php-container \
./phpunit --configuration config.xml
is running the tests fine and shows the output,
DOCKER_HOST=tcp://localhost:8888 docker exec php-container \
./phpunit --configuration config.xml
terminates immediately without any output and exit code 0 (according to echo $?
run directly afterwards). Any idea what might cause this issue or how to analyze it?
Notes:
- The output of
andDOCKER_HOST=tcp://localhost:8888 docker exec php-container \ ./phpunit --version
is shown. It looks like I only can’t run those tests that access the database or do something else that not all tests do. If I execDOCKER_HOST=tcp://localhost:8888 docker exec php-container \ ./phpunit ./some-test-directory
ps
in the container, I see that the phpunit processes never terminate. But what does that all have to do withDOCKER_HOST
beingtcp://localhost:8888
and notssh://test.server
?
Versions
Mac
- Docker version 20.10.7
- docker-compose version 1.29.2, build 5becea4c
- OpenSSH_8.1p1, LibreSSL 2.7.3
test.server
- Docker version 20.10.7
- OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
- socat version 1.7.3.3 on Oct 26 2019 17:42:04
PHP application/container:
- Docker Image
php:7.3-apache
- PHPUnit 4.8.36 by Sebastian Bergmann and contributors.