Docker与Linux共享的文件夹 [英] Docker shared folder with Linux

查看:84
本文介绍了Docker与Linux共享的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在与docker共享资源时遇到问题.我有文件夹

Hello I have problem with sharing resources with docker. I got folder

文档/卷/

在文件夹Volume中,我有文件data.txt现在,当我运行这样的图像时:

In folder Volume I have file data.txt Now when I run image like this:

docker run -v/Documents/Volume:/Volume -it busybox

docker run -v /Documents/Volume:/Volume -it busybox

我希望在卷Volume中可以看到文件data.txt,但文件丢失.因此,我通过命令在卷"文件夹中创建了新文件:

I would expect that in folder Volume I will see file data.txt but file is missing. So I create new file in folder Volume by command:

回声"Hello world"> test.txt

echo "Hello world" > test.txt

现在我希望在/Documents/Volume/

Now I`m expecting that file test.txt is visible in /Documents/Volume/

为什么我看不到在docker中创建的文件,而为什么我看不到从docker创建的文件?

Why I can't see files created in docker and from docker I can't see OS files?

可能我丢失了一些东西.

Probably I'm missing something.

推荐答案

-v 体积参数期望路径为绝对路径.

-v volume parameter expects path to be absolute.

您需要将完整路径传递给该文件夹,例如:

You need to pass full path to the folder like:

/var/share/Volume 

但不仅仅是您所做的相对路径

but not just relative path you did just

Volume

当需要相对路径时,我会使用此技巧

I use this trick when need relative path

-v $(pwd)/Volume:/data/Volume

这篇关于Docker与Linux共享的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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