Docker 由于“dm_task_set_cookie 失败”而无法启动
Docker is unable to start due to `dm_task_set_cookie failed`
我在centos机器上使用命令
安装了docker
$ yum install docker
$ docker --version
Docker version 1.12.6, build 88a4867/1.12.6
当我开始时docker:
$ service docker start
Redirecting to /bin/systemctl start docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
$ systemctl status -l docker.service
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2017-08-27 23:30:54 PDT; 39s ago
Docs: http://docs.docker.com
Process: 21772 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
Main PID: 21772 (code=exited, status=1/FAILURE)
Aug 27 23:30:53 tintserver7200 systemd[1]: Starting Docker Application Container Engine...
Aug 27 23:30:53 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:53.373296685-07:00" level=info msg="libcontainerd: new containerd process, pid: 21780"
Aug 27 23:30:54 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:54.386669163-07:00" level=warning msg="devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section."
Aug 27 23:30:54 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:54.387270412-07:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: devmapper: Base Device UUID and Filesystem verification failed: devicemapper: Can't set cookie dm_task_set_cookie failed"
Aug 27 23:30:54 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:54.388221829-07:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devmapper: Base Device UUID and Filesystem verification failed: devicemapper: Can't set cookie dm_task_set_cookie failed"
Aug 27 23:30:54 tintserver7200 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 27 23:30:54 tintserver7200 systemd[1]: Failed to start Docker Application Container Engine.
Aug 27 23:30:54 tintserver7200 systemd[1]: Unit docker.service entered failed state.
Aug 27 23:30:54 tintserver7200 systemd[1]: docker.service failed.
安装信息:
$ uname -a
Linux tintserver7200 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
docker 守护程序显示 Can't set cookie dm_task_set_cookie failed
的多个错误:
$ sudo docker daemon -D
DEBU[0000] docker group found. gid: 386
DEBU[0000] Listener created for HTTP on unix (/var/run/docker.sock)
INFO[0000] libcontainerd: new containerd process, pid: 32755
DEBU[0000] libcontainerd: containerd connection state change: CONNECTING
DEBU[0000] libcontainerd: containerd connection state change: TRANSIENT_FAILURE
WARN[0000] containerd: low RLIMIT_NOFILE changing to max current=1024 max=4096
DEBU[0000] containerd: read past events count=0
DEBU[0000] containerd: supervisor running cpus=4 memory=7713 runtime=docker-runc runtimeArgs=[] stateDir=/var/run/docker/libcontainerd/containerd
DEBU[0000] containerd: grpc api on /var/run/docker/libcontainerd/docker-containerd.sock
DEBU[0001] Using default logging driver json-file
DEBU[0001] Golang's threads limit set to 54630
DEBU[0001] devicemapper: driver version is 4.34.0
DEBU[0001] devmapper: Generated prefix: docker-253:0-582605
DEBU[0001] devmapper: Checking for existence of the pool docker-253:0-582605-pool
DEBU[0001] devmapper: Pool doesn't exist. Creating it.
ERRO[0001] [graphdriver] prior storage driver "devicemapper" failed: devicemapper: Can't set cookie dm_task_set_cookie failed
DEBU[0001] Cleaning up old mountid : start.
FATA[0001] Error starting daemon: error initializing graphdriver: devicemapper: Can't set cookie dm_task_set_cookie failed
如何解决错误 Can't set cookie dm_task_set_cookie failed
?
修复了我做了回显'y' |须藤 dmsetup udevcomplete_all
并且能够启动
由于many others遇到了这个问题(或跳转到下面的解决方案),所以在这里对原始question/answer进行澄清:
这里的一般问题是 Docker 的早期版本可能 devicemapper
泄漏 semaphores/cookies 到容器的挂载 space 之外。对我来说,这是在多次快速调用 docker build
、run
、rm
、stop
等
之后发生的
这可能导致系统的信号量数组在未被清除的情况下填满,这将阻止所有 docker 命令工作(并可能影响依赖于这些共享信号量的其他系统功能)。
您可以通过 increasing the number of semaphore arrays 或像我下面那样清除一些旧数组来解决这个问题。
接受的答案使用 clearing all semaphores 和 dmsetup udevcomplete_all
,但如果您有其他容器或进程依赖这些 cookies/semaphores。
,您可能不想这样做
相反,请检查您的 semaphore arrays -- 这些在我的机器上已满(128 个阵列):
$ ipcs -u
------ Semaphore Status --------
used arrays = 128
allocated semaphores = 1136
------ Messages Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes
------ Shared Memory Status --------
segments allocated 2
pages allocated 20057
pages resident 16214
pages swapped 2
Swap performance: 0 attempts 0 successes
这些信号量对应于 dm cookie,如 ipcs
和 dmsetup udevcookies
所示(仅显示最近的 cookie;查找匹配的 semid
):
$ ipcs -s -t
semid owner last-op last-changed
540278908 root Sat Jun 13 10:03:57 2020 Sat Jun 13 10:03:57 2020
548634749 root Sat Jun 13 10:09:22 2020 Sat Jun 13 10:09:22 2020
555876478 root Sat Jun 13 10:14:05 2020 Sat Jun 13 10:14:05 2020
572096639 root Sat Jun 13 11:43:42 2020 Sat Jun 13 11:43:42 2020
...
$ dmsetup udevcookies
Cookie Semid Value Last semop time Last change time
0xd4d819c 540278908 1 Sat Jun 13 10:03:57 2020 Sat Jun 13 10:03:57 2020
0xd4d8d60 548634749 1 Sat Jun 13 10:09:22 2020 Sat Jun 13 10:09:22 2020
0xd4d8eca 555876478 1 Sat Jun 13 10:14:05 2020 Sat Jun 13 10:14:05 2020
0xd4d7263 572096639 1 Sat Jun 13 11:43:42 2020 Sat Jun 13 11:43:42 2020
...
为了避免影响旧的 semaphores/cookies,我想使用 msetup udevreleasecookie <cookie ID>
:
只发布特定日期的 cookie
# filter the list of cookies, get the IDs, and feed it to udevreleasecookie:
$ REGEX_STR="Jun 13" # change to whatever filter you need
$ dmsetup udevcookies | grep -E "$REGEX_STR" | awk '{ print }' | xargs -n1 dmsetup udevreleasecookie
# check that the semaphores are gone
$ ipcs -s -t | grep -E "root" | grep -E "$REGEX_STR"
...
$
这让我可以再次 运行 docker
命令。
我在centos机器上使用命令
安装了docker$ yum install docker
$ docker --version
Docker version 1.12.6, build 88a4867/1.12.6
当我开始时docker:
$ service docker start
Redirecting to /bin/systemctl start docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
$ systemctl status -l docker.service
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2017-08-27 23:30:54 PDT; 39s ago
Docs: http://docs.docker.com
Process: 21772 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
Main PID: 21772 (code=exited, status=1/FAILURE)
Aug 27 23:30:53 tintserver7200 systemd[1]: Starting Docker Application Container Engine...
Aug 27 23:30:53 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:53.373296685-07:00" level=info msg="libcontainerd: new containerd process, pid: 21780"
Aug 27 23:30:54 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:54.386669163-07:00" level=warning msg="devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section."
Aug 27 23:30:54 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:54.387270412-07:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: devmapper: Base Device UUID and Filesystem verification failed: devicemapper: Can't set cookie dm_task_set_cookie failed"
Aug 27 23:30:54 tintserver7200 dockerd-current[21772]: time="2017-08-27T23:30:54.388221829-07:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devmapper: Base Device UUID and Filesystem verification failed: devicemapper: Can't set cookie dm_task_set_cookie failed"
Aug 27 23:30:54 tintserver7200 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 27 23:30:54 tintserver7200 systemd[1]: Failed to start Docker Application Container Engine.
Aug 27 23:30:54 tintserver7200 systemd[1]: Unit docker.service entered failed state.
Aug 27 23:30:54 tintserver7200 systemd[1]: docker.service failed.
安装信息:
$ uname -a
Linux tintserver7200 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
docker 守护程序显示 Can't set cookie dm_task_set_cookie failed
的多个错误:
$ sudo docker daemon -D
DEBU[0000] docker group found. gid: 386
DEBU[0000] Listener created for HTTP on unix (/var/run/docker.sock)
INFO[0000] libcontainerd: new containerd process, pid: 32755
DEBU[0000] libcontainerd: containerd connection state change: CONNECTING
DEBU[0000] libcontainerd: containerd connection state change: TRANSIENT_FAILURE
WARN[0000] containerd: low RLIMIT_NOFILE changing to max current=1024 max=4096
DEBU[0000] containerd: read past events count=0
DEBU[0000] containerd: supervisor running cpus=4 memory=7713 runtime=docker-runc runtimeArgs=[] stateDir=/var/run/docker/libcontainerd/containerd
DEBU[0000] containerd: grpc api on /var/run/docker/libcontainerd/docker-containerd.sock
DEBU[0001] Using default logging driver json-file
DEBU[0001] Golang's threads limit set to 54630
DEBU[0001] devicemapper: driver version is 4.34.0
DEBU[0001] devmapper: Generated prefix: docker-253:0-582605
DEBU[0001] devmapper: Checking for existence of the pool docker-253:0-582605-pool
DEBU[0001] devmapper: Pool doesn't exist. Creating it.
ERRO[0001] [graphdriver] prior storage driver "devicemapper" failed: devicemapper: Can't set cookie dm_task_set_cookie failed
DEBU[0001] Cleaning up old mountid : start.
FATA[0001] Error starting daemon: error initializing graphdriver: devicemapper: Can't set cookie dm_task_set_cookie failed
如何解决错误 Can't set cookie dm_task_set_cookie failed
?
修复了我做了回显'y' |须藤 dmsetup udevcomplete_all 并且能够启动
由于many others遇到了这个问题(或跳转到下面的解决方案),所以在这里对原始question/answer进行澄清:
这里的一般问题是 Docker 的早期版本可能 devicemapper
泄漏 semaphores/cookies 到容器的挂载 space 之外。对我来说,这是在多次快速调用 docker build
、run
、rm
、stop
等
这可能导致系统的信号量数组在未被清除的情况下填满,这将阻止所有 docker 命令工作(并可能影响依赖于这些共享信号量的其他系统功能)。
您可以通过 increasing the number of semaphore arrays 或像我下面那样清除一些旧数组来解决这个问题。
接受的答案使用 clearing all semaphores 和 dmsetup udevcomplete_all
,但如果您有其他容器或进程依赖这些 cookies/semaphores。
相反,请检查您的 semaphore arrays -- 这些在我的机器上已满(128 个阵列):
$ ipcs -u
------ Semaphore Status --------
used arrays = 128
allocated semaphores = 1136
------ Messages Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes
------ Shared Memory Status --------
segments allocated 2
pages allocated 20057
pages resident 16214
pages swapped 2
Swap performance: 0 attempts 0 successes
这些信号量对应于 dm cookie,如 ipcs
和 dmsetup udevcookies
所示(仅显示最近的 cookie;查找匹配的 semid
):
$ ipcs -s -t
semid owner last-op last-changed
540278908 root Sat Jun 13 10:03:57 2020 Sat Jun 13 10:03:57 2020
548634749 root Sat Jun 13 10:09:22 2020 Sat Jun 13 10:09:22 2020
555876478 root Sat Jun 13 10:14:05 2020 Sat Jun 13 10:14:05 2020
572096639 root Sat Jun 13 11:43:42 2020 Sat Jun 13 11:43:42 2020
...
$ dmsetup udevcookies
Cookie Semid Value Last semop time Last change time
0xd4d819c 540278908 1 Sat Jun 13 10:03:57 2020 Sat Jun 13 10:03:57 2020
0xd4d8d60 548634749 1 Sat Jun 13 10:09:22 2020 Sat Jun 13 10:09:22 2020
0xd4d8eca 555876478 1 Sat Jun 13 10:14:05 2020 Sat Jun 13 10:14:05 2020
0xd4d7263 572096639 1 Sat Jun 13 11:43:42 2020 Sat Jun 13 11:43:42 2020
...
为了避免影响旧的 semaphores/cookies,我想使用 msetup udevreleasecookie <cookie ID>
:
# filter the list of cookies, get the IDs, and feed it to udevreleasecookie:
$ REGEX_STR="Jun 13" # change to whatever filter you need
$ dmsetup udevcookies | grep -E "$REGEX_STR" | awk '{ print }' | xargs -n1 dmsetup udevreleasecookie
# check that the semaphores are gone
$ ipcs -s -t | grep -E "root" | grep -E "$REGEX_STR"
...
$
这让我可以再次 运行 docker
命令。