如何将文件从Windows主机复制到Docker容器 [英] How to copy files from Windows host to Docker container

查看:1408
本文介绍了如何将文件从Windows主机复制到Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一种快速的解决方案,将本地文件复制到Windows上的Docker容器。我无法在其他Stack Overflow解决方案中找到它。

Looking for a quick solution to copy local files to a Docker container on Windows. I wasn't able to find this in other Stack Overflow solutions.

您可能会称其为将Windows本地驱动器安装在Docker容器中。

You might call this mounting a local drive on Windows within a docker container.

推荐答案

从任务栏上的图标打开Docker设置:

Open the Docker settings from the icon on the taskbar:

转到共享驱动器并使您的容器可以访问本地驱动器:

Go to 'Shared Drives' and enable your local drive to be made accessible to your containers:

现在,您可以将共享驱动器中的文件夹作为卷添加到容器中。使用Docker中的 nginx 示例获取入门指南

Now you can add folders from your shared drive as a volume in a container. Using the nginx example from the Docker getting started guide:

docker run -it -vc:/用户:/ data nginx / bin / bash

这将为您提供外壳程序访问权限,您可以在其中在nginx容器的/ data目录中找到本地文件(c:/ Users)。

That will give you shell access, where you can find your local files (c:/Users) in the /data directory of your nginx container.

这篇关于如何将文件从Windows主机复制到Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆