An error occurred trying to connect: get http: / / var / run/ docker.sock/v1 .21/containers/json?all

start the container error An error occurred trying to connect: Get http:///var/run/docker.sock/v1.21/containers/json?all

Internet search data three steps to solve:

  1. Stop docker daemon
  2. sudo rm/var/lib/docker/network/files/local – kv. Db
  3. Start docker daemon but failed to solve my problem.

    shows UUID when viewing dockre status:

    qian:/var/lib/docker/devicemapper/devicemapper # systemctl status docker -l
    docker.service - Docker Application Container Engine
       Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
       Active: failed (Result: exit-code) since Fri 2017-03-31 10:15:21 EDT; 45s ago
         Docs: http://docs.docker.com
      Process: 34204 ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE)
     Main PID: 34204 (code=exited, status=1/FAILURE)
    
    Mar 31 10:15:21 qian docker[34204]: time="2017-03-31T10:15:21.084102345-04: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."
    Mar 31 10:15:21 qian docker[34204]: time="2017-03-31T10:15:21.098182020-04:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: devmapper: Base Device UUID and Filesystem verification failed.devmapper: Current Base Device UUID: does not match with stored UUID:ecfee58a-4aef-41e5-888b-e1588b90f325. Possibly using a different thin pool than last invocation"
    Mar 31 10:15:21 qian docker[34204]: time="2017-03-31T10:15:21.098304502-04:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devmapper: Base Device UUID and Filesystem verification failed.devmapper: Current Base Device UUID: does not match with stored UUID:ecfee58a-4aef-41e5-888b-e1588b90f325. Possibly using a different thin pool than last invocation"

    looking at the disk UUID found that there are fewer disks dm-0 or * than the normal container

    qian:/var/lib/docker/devicemapper/devicemapper # ls -al /dev/disk/by-uuid/
    total 0
    drwxr-xr-x 2 root root 100 Mar 30 19:13 .
    drwxr-xr-x 5 root root 100 Mar 14 09:56 ..
    lrwxrwxrwx 1 root root  10 Mar 14 09:56 ddaefbae-cc5e-4579-b2dc-24340323ccde -> ../../sda2
    lrwxrwxrwx 1 root root  10 Mar 14 09:56 eabdb089-f65f-4150-ac14-7e2deaca1d85 -> ../../sda1
    lrwxrwxrwx 1 root root  10 Mar 14 09:56 ecfee58a-4aef-41e5-888b-e1588b90f325 -> ../../sda3

    check the container device PID, found and normal is not the same, normal is UUID, my display as PTUUID

    qian:/var/lib/docker/devicemapper/devicemapper # blkid /dev/mapper/docker-8\:3-126130724-pool 
    /dev/mapper/docker-8:3-126130724-pool: PTUUID="d541fadc" PTTYPE="dos" 

    at this point there is no way to continue to search for the cause, and I can confirm that the disk UUID associated with the container was indeed not found on my node.

    view the docker uuid associated in/var/lib/docker/devicemapper/metadata/deviceset – metadata file.

    my final solution is to delete the docker related folder /etc/docker /var/lib/docker reinstall docker…

Read More: