简体   繁体   English

将文件从容器发送到主机

[英]Send file from container to host

This is what I tried: 这是我尝试的:

Dockerfile: Dockerfile:

ENTRYPOINT go test ./tests -v .>/outputs/report.txt

Command line: 命令行:

docker run test -v /outputs:/outputs 

I expect that the newly generated report.txt will be available in the host in the same directory. 我希望新生成的report.txt将在同一目录的主机中可用。 What am I missing here? 我在这里想念什么?

I think that you almost made it. 我认为您几乎做到了。

Try to map the volume before image name. 尝试在映像名称之前映射该卷。

Instead: docker run test -v /outputs:/outputs 相反: docker run test -v /outputs:/outputs

Use: docker run -v /outputs:/outputs test 使用: docker run -v /outputs:/outputs test

This command will bind your local /outputs with the /outputs in the container. 此命令会将您的本地/outputs与容器中的/outputs绑定。 And remember, all commands after image name will pass a command to the container. 记住,映像名称后的所有命令都将command传递给容器。

For more information see: Docker run command docs and Docker volume docs 有关更多信息,请参阅: Docker run command docsDocker volume docs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM