如何在docker-machine中使用docker-compose将文件从docker容器复制到主机 [英] How to copy files from docker container to host using docker-compose in docker-machine
问题描述
我在gradle容器中生成了用于硒测试的报告,我试图将文件从docker容器复制到本地主机。作为解决方法,我使用了docker cp将文件从容器复制到本地,并且可以正常工作。如何使用docker-compose卷实现它。
I have reports generated in gradle container for my selenium tests, I am trying to copy the files from docker container to local host. As a work around, I have used docker cp to copy files from container to my local and it works. How to achieve it with docker-compose volumes.
下面是我的 docker-compose.yml
version: "3 "
services:
selenium-hub:
image: selenium/hub
container_name: selenium-hub_compose
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome-debug
container_name: selenium-chrome
depends_on:
- selenium-hub
ports:
- "5900"
environment:
- http_proxy=http://x.x.x.x:83
- https_proxy=http://x.x.x.x:83
- HUB_HOST=selenium-hub
- HUB_PORT=4444
gradle:
image: gradle:jdk8
container_name: selenium-gradle
build:
context: .
dockerfile: dockerfile
我运行命令 docker-compose up
->它运行硒测试并在容器中生成报告。
I run the command docker-compose up
-> it runs the selenium tests and generates the report in the container.
有人可以帮忙吗?
推荐答案
-
在虚拟框中关闭计算机->在虚拟框中更改高级设置
Power off the machine in Virtual box -> Change the Advanced settings in Virtual box
转到虚拟框中的共享文件夹
Give Path :: C:\DockerResults:为文件夹名称提供逻辑名
Goto Shared Folders in Virtual box Give Path :: C:\DockerResults : Give a logical name for the Folder name
使用以下命令在DockerTerminal中重新启动计算机
docker-machine restart default
Restart the machine in DockerTerminal with the below command docker-machine restart default
在计算机启动后,打开虚拟框
在虚拟机中创建目录:sudo mkdir / Results
After machine is started open the Virtual box Create a directory in the Virtual machine : sudo mkdir /Results
容量:
- /DockerResults:/home/Reports/
这篇关于如何在docker-machine中使用docker-compose将文件从docker容器复制到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!