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.