无法将文件从docker-compose挂载复制到主机 [英] Unable to copy file from docker-compose mount to host
问题描述
我无法将Selenium测试生成的文件复制到安装到主机的docker容器内的文件夹中。
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
testResultsReport内部生成的文件名运行docker-compose时的文件夹是 TestResultsReport.HTML
Name of the file generated inside testResultsReport folder when running docker-compose is TestResultsReport.HTML
因为我的测试在端口<$上的硒服务器中运行c $ c> 4444 ,sho我可以把音量放在那里吗?我试图这样做,但仍然没有将我的HTML文件复制到主机上?
我确认我在compose之外运行测试时生成了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.
我也尝试过./testResultsReport,但是它在根目录中添加了一个名为name的文件夹的testResultsReport,什么也没做。因此,我使用了./tests/testResultsReport,但仍未获取文件。
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.
推荐答案
使用正确的文件夹和绝对路径进行工作。谢谢@chrisz
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挂载复制到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!