代码之家  ›  专栏  ›  技术社区  ›  Zaks

Docker无法启动,因为“dm\u task\u set\u cookie失败”`

  •  2
  • Zaks  · 技术社区  · 7 年前

    $ 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
    

    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
    

    无法设置cookie dm\u task\u set\u cookie失败 ?

    2 回复  |  直到 4 年前
        1
  •  4
  •   Zaks    7 年前

    修复了I did echo“y”| sudo dmsetup udevcomplete|u all 它能够启动

        2
  •  0
  •   ascendants    4 年前

    many others 遇到此问题(或跳到下面的解决方案):

    这里的一般问题是早期版本的Docker可能 devicemapper 将信号量/cookie泄漏到容器的装载空间之外。对我来说,这是在多次快速给docker打电话之后发生的 build , run , rm stop

    这可能会导致系统的信号量数组在未清除的情况下填满,这将阻止所有docker命令工作(并可能影响依赖于这些共享信号量的其他系统功能)。

    你可以通过 increasing the number of semaphore arrays ,或者像下面这样清除一些旧数组。


    公认答案使用 clearing all semaphores dmsetup udevcomplete_all ,但如果有其他容器或进程依赖于这些cookie/信号量,则可能不希望这样做。

    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 cookies,如所示 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
    ...
    

    为了避免影响旧的信号量/cookie,我想使用 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 $1 }' | xargs -n1 dmsetup udevreleasecookie
    
    # check that the semaphores are gone
    $ ipcs -s -t | grep -E "root" | grep -E "$REGEX_STR"    
    ...
    $
    

    这让我可以跑步 docker