Unable to copy file from docker-compose mount to h

2020-03-24 06:48发布

I am unable to copy a file generated by my Selenium tests in a folder inside docker container mounted to host machine.

Here is how my compose file look like

  selenium:
    image: 'selenium/standalone-chrome'
    expose:
      - "4444"
  tests:
    build:
      context: ./tests
      dockerfile: Dockerfile
    depends_on:
      - selenium
      - web
    volumes:
      - /testResultsReport:/testResultsReport

This is how my directory structure looks like.

\
 - docker-compose.yml
 - build scripts
 - tests
   - testResultsReport
   - Test scripts

Name of the file generated inside testResultsReport folder when running docker-compose is TestResultsReport.HTML

As my tests are running inside selenium server on port 4444, should I mount my volume there? I tried doing that to but still not getting my html file copied to host machine? I confirmed that my html file is generated when i run my tests outside compose.

I also tried ./testResultsReport however it added a folder in root with name of testResultsReport and did nothing. So I used ./tests/testResultsReport but still not getting file.

1条回答
该账号已被封号
2楼-- · 2020-03-24 07:09

Worked by using right folder and absolute path. Thanks @chrisz

selenium:
    image: 'selenium/standalone-chrome'
    expose:
      - "4444"
  tests:
    build:
      context: ./tests
      dockerfile: Dockerfile
    depends_on:
      - selenium
      - web
    volumes:
      - ./tests/testResultsReport:/tests/testResultsReport
查看更多
登录 后发表回答