如何在不更改默认值的情况下将特定命名的 docker 卷存储在特定位置? [英] How to store a specific named docker volume at a specific location without changing the default?
问题描述
我想为我的一个容器创建一个命名卷.
I would like to create a named volume for one of my containers.
与我运行的其他容器相比,此容器需要更多的存储空间,因此我想将该特定卷存储在具有大量可用空间的不同磁盘上.
This container will need a lot more storage than other containers I run, so I would like to store that particular volume on a different disk that has lots of free space.
我仍然想要默认磁盘上的其他卷,只有一个命名的卷应该放在另一个磁盘上.
I still want the other volumes on the default disk, only that one named volume should go on another disk.
我不想使用绑定安装,因为它会使备份和迁移变得更加复杂.
I don't want to use a bind mount because it will make backing up and migrating more complicated.
我能想到的唯一选择是在创建卷后(在容器停止时)手动移动卷,并从 /var/lib/docker/... 中的原始位置创建符号链接
到另一个硬盘上的新位置.虽然这是非常手动的,这让我认为必须有更好的方法.
The only option I can think of is to manually move the volume after it is created (while the container is stopped), and create a symlink from its original location in /var/lib/docker/...
to the new location on the other hard drive. This is very manual though, which leads me to think there must be a better way.
实现这一目标的推荐方法是什么?
What is the recommended way of achieving this?
推荐答案
使用本地卷驱动:
docker volume create -d local -o type=none -o o=bind -o device=/host/path volname
(取自 此 github 评论)
这篇关于如何在不更改默认值的情况下将特定命名的 docker 卷存储在特定位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!