[solved] Cannot retrieve junit tests results file from a docker compose image (in private gitlab)

File written in volume-mounted docker image is not visible in the ci script

I have a complex (at leas for me) CI process which involves multi-stage docker images, docker-compose, pytest tests, c+±based server and postgres database. Everything works fine except that the junit xml files that are generated by tests, and that should be available in a folder mounted as a volume, are not present in the folder at the end of the CI script.

I created a simplified project to show the problem. It fails the same way in our internal gitlab and runner. I thus exported it and imported in gitlab.com, but there it works ! :
testserver-test-job (#2356512023) · Jobs · Gaël de Chalendar / ci_test · GitLab

I suppose there is a difference in versions or runner configuration but I cannot find what. I found some forum entries with things about volumes that should mount ‘/builds:/builds’ (Docker volumes not mounted when using docker:dind (#41227) · Issues · GitLab.org / GitLab FOSS · GitLab) and I tried that but it did not solve the problem and I’m not sure it is related.

Here is the complete trace of the failed internal test:

e[0KRunning with gitlab-runner 14.10.0 (c6bb62f6)e[0;m
e[0K  on Dind runner on is234070 yi9vHuKWe[0;m
e[0Ke[0Ke[36;1mPreparing the "docker" executore[0;me[0;m
e[0KUsing Docker executor with image docker/compose ...e[0;m
e[0KStarting service docker:dind ...e[0;m
e[0KPulling docker image docker:dind ...e[0;m
e[0KUsing docker image sha256:a072474332af3e4cf06e349685c4cea8f9e631f0c5cab5b582f3a3ab4cff9b6a for docker:dind with digest docker@sha256:210076c7772f47831afaf7ff200cf431c6cd191f0d0cb0805b1d9a996e99fb5e ...e[0;m
e[0KWaiting for services to be up and running...e[0;m

e[0;33m*** WARNING:e[0;m Service runner-yi9vhukw-project-1137-concurrent-0-12ed57b6f959bbb2-docker-0 probably didn't start properly.

Health check error:
create service container: Error response from daemon: conflicting options: host type networking can't be used with links. This would result in undefined behavior (docker.go:1165:0s)

Service container logs:


e[0KPulling docker image docker/compose ...e[0;m
e[0KUsing docker image sha256:c3e188a6b38fa7f54cac9963e11b049f7701b8a6354962218b6bbab0fba07bdf for docker/compose with digest docker/compose@sha256:b60a020c0f68047b353a4a747f27f5e5ddb17116b7b018762edfb6f7a6439a82 ...e[0;m
e[0Ke[0Ke[36;1mPreparing environmente[0;me[0;m
Running on runner-yi9vhukw-project-1137-concurrent-0 via b5f671220ef3...
e[0Ke[0Ke[36;1mGetting source from Git repositorye[0;me[0;m
e[32;1mFetching changes with git depth set to 50...e[0;m
Reinitialized existing Git repository in /builds/gchalendar/ci_test/.git/
e[32;1mChecking out 0b748609 as gchalendar-master-patch-59417...e[0;m
Removing shared/

e[32;1mSkipping Git submodules setupe[0;m
e[0Ke[0Ke[36;1mExecuting "step_script" stage of the job scripte[0;me[0;m
e[0KUsing docker image sha256:c3e188a6b38fa7f54cac9963e11b049f7701b8a6354962218b6bbab0fba07bdf for docker/compose with digest docker/compose@sha256:b60a020c0f68047b353a4a747f27f5e5ddb17116b7b018762edfb6f7a6439a82 ...e[0;m
e[32;1m$ echo "Test testserver:"e[0;m
Test testserver:
e[32;1m$ pwde[0;m
e[32;1m$ echo "SHARED_PATH is '$SHARED_PATH'"e[0;m
SHARED_PATH is '/builds/gchalendar/ci_test/shared'
e[32;1m$ mkdir $SHARED_PATHe[0;m
e[32;1m$ docker versione[0;m
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:22:56 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:45:53 2022
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
  Version:          0.19.0
  GitCommit:        de40ad0
e[32;1m$ docker-compose versione[0;m
docker-compose version 1.26.2, build eefe0d3
docker-py version: 4.2.2
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
e[32;1m$ docker-compose -f docker-compose.yml build --no-cachee[0;m
Building testserver_test
Step 1/4 : FROM debian:11
 ---> a11311205db1
Step 2/4 : RUN install -d /usr/share/apps/test/tests/test
 ---> Running in ea923b25205b
Removing intermediate container ea923b25205b
 ---> 312747f260f5
Step 3/4 : WORKDIR /usr/share/apps/test/tests/test
 ---> Running in f85b29494309
Removing intermediate container f85b29494309
 ---> 92195afa3ab9
Step 4/4 : CMD ["touch", "/testserver_test_results/testserver-tests-junit.xml"]
 ---> Running in 2956663b76ea
Removing intermediate container 2956663b76ea
 ---> 88aeb5c8ff6a
Successfully built 88aeb5c8ff6a
Successfully tagged ci_test_testserver_test:latest
e[32;1m$ SHARED_PATH=$SHARED_PATH docker-compose -f docker-compose.yml up --abort-on-container-exit --exit-code-from testserver_teste[0;m
Recreating ci_test_testserver_test_1 ... 
Recreating ci_test_testserver_test_1 ... e[32mdonee[0m
e[1BAttaching to ci_test_testserver_test_1
e[36mci_test_testserver_test_1 exited with code 0
e[0mAborting on container exit...
e[32;1m$ ls -l $SHARED_PATHe[0;m
total 0
e[32;1m$ cp $SHARED_PATH/*-junit.xml .e[0;m
cp: can't stat '/builds/gchalendar/ci_test/shared/*-junit.xml': No such file or directory
e[0Ke[0Ke[36;1mUploading artifacts for failed jobe[0;me[0;m
e[32;1mUploading artifacts...e[0;m
e[0;33mWARNING: *-junit.xml: no matching files           e[0;m 
e[31;1mERROR: No files to upload                         e[0;m 
e[0Ke[31;1mERROR: Job failed: exit code 1

Problem solved. It was in fact the problem I suspected with the /builds:/builds volume but I made an error when I reinitialized the runner with this volume and thus it was still not used. After retrying with the correct runner initialization, it worked.

Can you please elaborate on the solution? Or point to the docs you used to set it up?