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

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

问题描述

我有(已经)一个数据容器,其容器被其他容器使用(--volumes-from)。

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

数据容器意外删除。

幸运的是,这个卷没有被删除。

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天全站免登陆