Docker-从主机访问容器内部的文件 [英] Docker - accessing files inside container from host

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

问题描述

我是docker的新手。

I am new to docker.

我运行了一个node-10图像,并在运行的容器中克隆了一个存储库,运行了应用程序,该应用程序启动了一个带有文件的服务器观察者。我需要访问容器内的代码库,并在Windows主机上运行的IDE中打开它。如果完成了,那么我还希望当我在IDE中更改文件时,这些更改会引起容器中的文件监视程序。

I ran a node-10 images and inside the running container I cloned a repository, ran the app which started a server with file watcher. I need to access the codebase inside the container, open it up in an IDE running on the windows host. If that is done, then I also want that as I change the files in the IDE these changes induce the filewatcher in the container.

我们将提供任何帮助。谢谢,

Any help is appreciated. Thanks,

推荐答案

您正在寻找的概念称为。您需要启动一个容器并在其中安装主机目录。对于容器,它将是一个常规文件夹,并在其中创建文件。对于您来说,它也是一个常规文件夹。

The concept you are looking for is called volumes. You need to start a container and mount a host directory inside it. For the container, it will be a regular folder, and it will create files in it. For you, it will also be a regular folder. Changes made by either side will be visible to another.

docker run -v /a/local/dir:/a/dir/in/your/container

请注意,尽管您可以遇到权限问题,您需要单独解决。

Note though that you can run into permission issues that you will need to figure out separately.

这篇关于Docker-从主机访问容器内部的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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