In order to run Docker in production, I am following the steps in https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/#configure-direct-lvm-mode-for-production
Everything seems to be working fine. But if I reboot for some reason, everything messes up. Even if I remove everything from /var/lib/docker
and I run lvremove, vgremove and pvremove
it still says Error starting daemon: error initializing graphdriver: devmapper: Unable to take ownership of thin-pool (docker-thinpool) that already has used data blocks
and resists to start.
I know there has to be some documentation that shows how to make direct-lvm settings persistent against reboots. Something automatically restores the settings after reboot. I could not find any.
So how do I achieve persistence for my direct-lvm settings?
答案 0 :(得分:4)
幸运的是,Docker社区中的某个人了解了这个问题并与之分享了他们的解决方案。解决方案是:https://github.com/projectatomic/docker-storage-setup。
apt install -y thin-provisioning-tools
mkdir /usr/lib/docker-storage-setup
mkdir /etc/sysconfig
git clone https://github.com/projectatomic/docker-storage-setup.git /opt/docker-storage-setup
cp /opt/docker-storage-setup/docker-storage-setup.sh /usr/bin/docker-storage-setup
cp /opt/docker-storage-setup/docker-storage-setup.service /lib/systemd/system/docker-storage-setup.service
cp /opt/docker-storage-setup/libdss.sh /usr/lib/docker-storage-setup
VG=docker DATA_SIZE=95%FREE STORAGE_DRIVER=devicemapper /opt/docker-storage-setup/docker-storage-setup.sh
systemctl enable docker-storage-setup
lvrename docker/thinpool docker/docker-pool
/lib/systemd/system/docker.service中systemd服务文件中的相关部分需要更新为--storage-opt=dm.thinpooldev=/dev/mapper/docker-docker--pool
答案 1 :(得分:4)
在bug report埃里克巴黎说:
如果您正在使用设备映射器(而不是环回)/ var / lib / docker包含元数据,通知docker有关设备映射器存储区域的内容。如果删除/ var / lib / docker,则元数据将丢失。然后Docker能够检测到精简池有数据,但是docker无法使用该信息。唯一的解决方案是删除精简池并重新创建它,以便精简池和/ var / lib / docker中的元数据都为空。
由于您提到的文档措辞,我遇到了同样的问题。步骤rm -rf /var/lib/docker.bk
只是在那时我删除了原始文件,导致失败。
使用pvremove -ff /dev/sda2
(我的lvm驱动器)并重新创建,擦除lvm分区中的签名,它对我有用。
我认为你的设置应该是持久的。
对我来说,在重启lsblk
没有显示我的lvm卷后,发生了另一个错误,ls /dev/mapper
。我使用的是Ubuntu,commit message表示其默认设置不支持(完全?)支持精简配置。在sudo apt-get install thin-provisioning-tools
命令sudo vgchange -ay docker
之后以及重新启动对我有效。