I have python tests that generate the results of the tests as HTML and XML files. When I run docker-compose, I want to find these results and mount them in a local volume.
docker-compose.yml
version "3.9"
services:
tests:
build: .
image: test-image
volumes:
- myLocalVolumes:/my/url/to/tests/results
volumes:
myLocalVolumes
I am using a MacBook. Any tips on how to find the URL of these test results.
I think it has to be taken from inside the container or stored somewhere in the computer.
2
Answers
The solution is there is a folder named results inside the project. That folder contains all the results of the tests as HTML and XML files. To mount that data, we will do: myLocalVolumes:/results. The complete docker-compose.yml will be
if your goal is to save test results. first find where the results are saved in the container. if your script/code write results to folder called
results
in the same working directoryyou should first find the working dir
you can find it in the Dockerfile
example:
WORKDIR /project
then mount the
results
directory to the docker volumeyou will find volume in the path
/var/lib/docker/volumes/myLocalVolumes
or in more simple way you can mount to a folder in the host machine
if your script/code generates individual files with different unique names it’s better to modify the code to put results into a directory so you can mount them easily.