Docker - 如何访问未附加到容器的卷? [英] Docker - How to access a volume not attached to a container?

查看:24
本文介绍了Docker - 如何访问未附加到容器的卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有(拥有)一个数据容器,其中包含其他容器使用的卷(--volumes-from).

I have (had) a data container which has a volume used by other containers (--volumes-from).

数据容器被意外删除了.

The data container has accidentally been removed.

谢天谢地,该卷没有被删除.

Thankfully the volume was not removed.

有什么方法可以重新运行数据容器并将其指向此卷?

Is there any way I can re run the data container and point it BACK to this volume?

推荐答案

有什么方法可以重新运行数据容器并将其指向这个卷?

Is there any way can re run the data container and point it BACK to this volume?

当然,我在如何从已删除的 Docker 容器中恢复数据?如何将其重新连接到数据?​​

您需要创建一个具有相同 VOLUME 的新容器(但它的路径 /var/lib/docker/volumes/... 将为空或带有初始内容)

You need to create a new container with the same VOLUME (but its path /var/lib/docker/volumes/... would be empty or with an initial content)

然后您将旧卷移动到新容器的卷的路径.

Then you move your legacy volume to the path of the volume of the new container.

更一般地说,每当我启动一个数据卷容器时,我在一个文件中注册它的卷路径(以重用它如果我的容器被意外移除,稍后路径)

More generally, whenever I start a data volume container, I register its volume path in a file (to reuse that path later if my container is accidentally removed)

这篇关于Docker - 如何访问未附加到容器的卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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