Docker 容器卷本地同步

Docker 容器卷本地同步

我正在尝试运行本地 Docker 注册表,并与 Dropbox 同步存储,这样如果我移动到不同的工作站,我就可以访问构建的虚拟机,而无需重建映像。

我已使用以下命令启动注册表:

docker run -d -p 5000:5000 --name td-registry -v /Users/andrew/Dropbox/Developer/Docker/Registry:/tmp/registry registry

然后,我推送一个我通过以下方式构建的示例图像:

docker push localhost:5000/ubunutu

现在,我希望看到某种文件或目录放入/Users/andrew/Dropbox/Developer/Docker/Registry;但事实并非如此:

$ ls -lah ~/Dropbox/Developer/Docker/Registry
total 0
drwxr-xr-x  2 andrew  staff    68B Sep 24 14:39 .
drwxr-xr-x  4 andrew  staff   136B Sep 24 16:42 ..

启动Registry容器时我是否错误地安装了数据卷?

编辑

这是 的输出docker push,因此它已成功推送。

The push refers to a repository [localhost:5000/ubuntu] (len: 1)
Sending image list
Pushing repository localhost:5000/ubuntu (1 tags)
511136ea3c5a: Image successfully pushed
bfb8b5a2ad34: Image successfully pushed
c1f3bdbd8355: Image successfully pushed
897578f527ae: Image successfully pushed
9387bcc9826e: Image successfully pushed
809ed259f845: Image successfully pushed
96864a7d2df3: Image successfully pushed
a037e7415015: Image successfully pushed
922d395cc25c: Image successfully pushed
f9317ffe9a11: Image successfully pushed
1a980360e853: Image successfully pushed
f759631e9b64: Image successfully pushed
194edb5b619b: Image successfully pushed
5cf96e6ae328: Image successfully pushed
b4d4b1e2e0b3: Image successfully pushed
921507f17768: Image successfully pushed
b9faffd3f579: Image successfully pushed
Pushing tag for rev [b9faffd3f579] on {http://localhost:5000/v1/repositories/ubuntu/tags/latest}

答案1

如果您使用官方注册表映像,则本地卷默认存储的路径为/tmp/registry。因此,这应该是您的挂载点。

docker run -d -p 5000:5000 --name td-registry -v /Users/andrew/Dropbox/Developer/Docker/Registry:/tmp/registry registry

这包含在持久存储主要自述文件的部分。

答案2

问题是 boot2docker。这些文件夹正在从 boot2docker 映像安装到容器中。据我所知,没有简单的方法可以将文件夹安装到 boot2docker 映像。

我的修复方法是删除 boot2docker 并启动一个额外的 Vagrant CoreOS VM,该 VM 运行带有已安装文件夹的单个注册表容器。

相关内容