I have a docker container which image is based on docker/compose
which I run with an option -v /var/run/docker.sock:/var/run/docker.sock
on a Ubuntu 18.04 docker host. Inside that docker image I start docker-compose up --abort-on-container-exit --build
. In my docker-compose.yml one of the services is specified this way
version: '3'
services:
test:
build: .
depends_on:
- hub
- chrome
volumes:
- './TestResults:/tests/TestResults'
networks:
- selenium-test
What happens is that docker image runs the tests and test results from the run go into /tests/TestResults/results.trx
file. When I was running docker-compose up --abort-on-container-exit --build
on a Ubuntu 18.04 docker host all was working perfectly fine, after tests completed I have tests results in TestResults/results.trx
on a host, because volume worked fine.
Now I need to run docker-compose up --abort-on-container-exit --build
in Azure DevOps agent which is runnning inside the docker container on the same Ubuntu 18.04 docker host. All works fine, but I have a problem with volume which is in docker-compose specified:
volumes:
- './TestResults:/tests/TestResults'
As I specify -v /var/run/docker.sock:/var/run/docker.sock
when I run agent in a docker, so all docker containers which created inside of a agent container in fact are created on docker host of a host machine, but not as docker inside of a docker. The problem appears with volume. After docker-compose up --abort-on-container-exit --build
finishes its work agent which runs in a docker wants to get test results from ./TestResults
folder, but for some reason nothing is in there as it seems it mounted host machine folder and I found the results on a host machine in a folder /azp/agent/_work/1/s/TestResults
, while agent which runs in docker needs those result inside the agent container in the same path /azp/agent/_work/1/s/TestResults
.
What do I do wrong and how do I fix that a container which I start inside of a container works with volumes correctly.