无法将文件从 docker-compose mount 复制到主机 [英] Unable to copy file from docker-compose mount to host
问题描述
我无法将 Selenium 测试生成的文件复制到安装到主机的 docker 容器内的文件夹中.
这是我的撰写文件的样子
硒:图像:'硒/独立铬'暴露:- 4444"测试:建造:上下文:./testsdockerfile: Dockerfile依赖于取决于:- 硒- 网络卷:-/testResultsReport:/testResultsReport
这是我的目录结构的样子.
<预><代码>- docker-compose.yml- 构建脚本- 测试- 测试结果报告- 测试脚本运行 docker-compose 时在 testResultsReport 文件夹中生成的文件名为 TestResultsReport.HTML
由于我的测试在 selenium 服务器中的 4444
端口上运行,我应该在那里安装我的卷吗?我尝试这样做,但仍然没有将我的 html 文件复制到主机?我确认我的 html 文件是在我在 compose 之外运行测试时生成的.
我也尝试过 ./testResultsReport 但是它在根目录中添加了一个名为 testResultsReport 的文件夹并且什么也没做.所以我使用了 ./tests/testResultsReport 但仍然没有得到文件.
使用正确的文件夹和绝对路径.谢谢@chrisz
硒:图像:'硒/独立铬'暴露:- 4444"测试:建造:上下文:./testsdockerfile: Dockerfile依赖于取决于:- 硒- 网络卷:- ./tests/testResultsReport:/tests/testResultsReport
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.
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
这篇关于无法将文件从 docker-compose mount 复制到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!