在Docker中挂载本地文件夹会导致目录为空 [英] Mounting a local folder in docker results in an empty directory

查看:93
本文介绍了在Docker中挂载本地文件夹会导致目录为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我的设置是

  • windows 10(1709 16299.967)
  • wsl(ubuntu 18.04)
  • 适用于Windows 2.0.0.2(30215)Engine 18.09.1的Docker

我正在尝试将本地开发文件夹作为卷挂载在Docker容器中,但是挂载的目录始终为空.我已经通过docker for Windows设置对话框为c:/启用了共享驱动器设置.

I'm trying to mount a local development folder as a volume within a docker container but the mounted directory is always empty. I have enabled the shared drive setting for c:/ through the docker for windows settings dialog.

我尝试通过WSL和powershell挂载本地目录,但在任何情况下都没有运气.我尝试过的命令是:

I have tried mounting the local directory through WSL and powershell with no luck in either case. The commands I have tried are :

docker run -it -v /c/code/bitbucket/my-api:/var/my-api -w "/var/my-api" centos:7
docker run -it -v c:/code/bitbucket/my-api:/var/my-api -w "/var/my-api" centos:7
docker run -it -v c:\code\bitbucket\my-api:/var/my-api -w "/var/my-api" centos:7

在WSL和powershell中,但所有结果都会导致/var/my-api文件夹为空

In both WSL and powershell but all result in an empty /var/my-api folder

如果我放置的文件夹不存在,则会出现以下错误:

By the way if I put a folder that does not exist I get the following error:

➜  docker run -it -v /c/code/bitbucket/my-apizzz:/var/my-apizzz -w "/var/my-apizzz" centos:7
docker: Error response from daemon: Mount denied:
The source path "C:/code/bitbucket/my-apizzz"
doesn't exist and is not known to Docker.
See 'docker run --help'.

所以我认为我使用的语法正确,只是docker似乎无法访问文件共享

So I think I am using the correct syntax it's just that docker can't seem to access the file share

推荐答案

我以前见过此问题.尝试在此处重置您的凭据:

I have seen this issue before. Try resetting your credentials here:

然后测试:

docker run --rm -v c:/code/bitbucket/my-api:/data alpine ls /data

这篇关于在Docker中挂载本地文件夹会导致目录为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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