如何启用docker的udev同步成功?

我已经从这个站点下载并安装了静态连接的docker 1.6.1 ,并在RHEL 7.1上运行它:

 [root@localhost bin]# ./docker -d WARN[0000] Udev sync is not supported. This will lead to unexpected behavior, data loss and errors INFO[0000] +job init_networkdriver() INFO[0000] +job serveapi(unix:///var/run/docker.sock) INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) INFO[0000] -job init_networkdriver() = OK (0) INFO[0000] Loading containers: start. INFO[0000] Loading containers: done. INFO[0000] docker daemon: 1.6.1 97cd073; execdriver: native-0.2; graphdriver: devicemapper INFO[0000] +job acceptconnections() INFO[0000] -job acceptconnections() = OK (0) INFO[0000] Daemon has completed initialization 

我可以看到有一个警告:“ Udev sync is not supported. This will lead to unexpected behavior, data loss and errors ”,并检查docker源代码后,我发现警告日志来自deviceset.go :

 func (devices *DeviceSet) initDevmapper(doInit bool) error { ...... // https://github.com/docker/docker/issues/4036 if supported := devicemapper.UdevSetSyncSupport(true); !supported { log.Warnf("Udev sync is not supported. This will lead to unexpected behavior, data loss and errors") } log.Debugf("devicemapper: udev sync support: %v", devicemapper.UdevSyncSupported()) ...... } 

devicemapper.UdevSetSyncSupport是这样的:

 // UdevSyncSupported returns whether device-mapper is able to sync with udev // // This is essential otherwise race conditions can arise where both udev and // device-mapper attempt to create and destroy devices. func UdevSyncSupported() bool { return DmUdevGetSyncSupport() != 0 } // UdevSetSyncSupport allows setting whether the udev sync should be enabled. // The return bool indicates the state of whether the sync is enabled. func UdevSetSyncSupport(enable bool) bool { if enable { DmUdevSetSyncSupport(1) } else { DmUdevSetSyncSupport(0) } return UdevSyncSupported() } 

我可以看到原因是启用udev同步失败。 如何成功启用udev同步?

更新:在检查dm_udev_set_sync_support的反汇编代码dm_udev_set_sync_support

 (gdb) disassemble dm_udev_set_sync_support Dump of assembler code for function dm_udev_set_sync_support: => 0x0000000000a3e4e0 <+0>: repz retq End of assembler dump. 

这是一个空的function,什么都不做,没有提到设置同步的支持。 这是否意味着这个静态构build的docker二进制文件是没有用的?

我不能重现你的问题; 我得到以下内容:

 (gdb) disassemble dm_udev_set_sync_support Dump of assembler code for function dm_udev_set_sync_support@plt: 0x0000000000403420 <+0>: jmpq *0xda8c92(%rip) # 0x11ac0b8 <dm_udev_set_sync_support@got.plt> 0x0000000000403426 <+6>: pushq $0x14 0x000000000040342b <+11>: jmpq 0x4032d0 

帮你个忙:忽略docker.io的构建,直接从RHEL获取Docker。 它在“额外”频道中可用。 虽然通常会比上游版本落后几周(例如1.6而不是1.7),但它也经过了充分的测试,并保证实际工作。

经过一些有用的反馈修改我的原始答案:

你必须使用一个动态二进制文件:“当然,如果使用一个静态链接的二进制文件,udev同步是不可能的,因此会导致腐败问题,这对于RedHat(维护devicemapper驱动的人)使用一个动态链接的二进制(他们在他们的回购中提供)。

就在1.7.0版本docker开始提供rpms和debs动态链接二进制文件的主要安装脚本@ get.docker.com(和易于回收匹配)。 有了这些二进制文件,udev sync就被支持,devicemapper应该可以正常工作了。“

幸运的是,自创建OP之后,Docker更改了其存储库以提供动态二进制文件。

参考: https : //github.com/docker/docker/issues/13179