Fixing a Docker Bug: /var/run/docker.sock

I encountered a Docker bug that took a long time to fix. Every time I tried to run Docker on Ubuntu 14.04, I would see this error:

  1. $ docker ps
  2. An error occurred trying to connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: read unix @->/var/run/docker.sock: read: connection reset by peer

This bug was quite time consuming to figure out.

tl;dr The solution for me was to purge docker-engine and then delete /var/lib/docker, reboot, and then reinstall docker-engine. The answer was buried in this discussion.

  1. $ sudo apt-get autoremove --purge docker-engine
  2.  
  3. # Nothing worked until I added this step
  4. $ sudo rm -rfv /var/lib/docker
  5.  
  6. # Reboot here
  7.  
  8. $ sudo apt-get update
  9. $ sudo apt-get install docker-engine

Purging docker-engine, rebooting, and reinstalling, didn't work. The fix required removing the /var/lib/docker directory.

Here is more system information for anyone else who encounters this problem.

  1. $ docker version
  2. Client:
  3. Version: 1.12.0
  4. API version: 1.24
  5. Go version: go1.6.3
  6. Git commit: 8eab29e
  7. Built: Thu Jul 28 22:00:36 2016
  8. OS/Arch: linux/amd64
  9. An error occurred trying to connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version: read unix @->/var/run/docker.sock: read: connection reset by peer
  10.  
  11.  
  12.  
  13. $ docker info
  14. An error occurred trying to connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: read unix @->/var/run/docker.sock: read: connection reset by peer
  15.  
  16.  
  17.  
  18. $ dpkg -l | grep docker
  19. ii docker-engine 1.12.0-0~trusty amd64 Docker: the open-source application container engine
  20. rc docker.io 1.6.2~dfsg1-1ubuntu4~14.04.1 amd64 Linux container runtime
  21.  
  22.  
  23. # Ubuntu 14.04
  24. $ uname -a
  25. Linux z84302 3.13.0-93-generic #140-Ubuntu SMP Mon Jul 18 21:21:05 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

This recommended solution didn't work:

  1. $ sudo service docker stop
  2. docker stop/waiting
  3.  
  4. $ sudo rm /var/lib/docker/network/files/local-kv.db
  5. rm: cannot remove ‘/var/lib/docker/network/files/local-kv.db’: No such file or directory
  6.  
  7. $ sudo service docker start
  8. docker start/running, process 26994

More info:

  1. $ tail /var/log/syslog
  2. Aug 13 15:28:37 z84302 kernel: [ 3185.793539] init: docker main process ended, respawning
  3. Aug 13 15:28:38 z84302 kernel: [ 3186.898659] type=1400 audit(1471127318.303:912): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="docker-default" pid=16862 comm="apparmor_parser"
  4. Aug 13 15:28:38 z84302 kernel: [ 3186.963235] init: docker main process (16837) terminated with status 1
  5. Aug 13 15:28:38 z84302 kernel: [ 3186.963244] init: docker main process ended, respawning
  6. Aug 13 15:28:39 z84302 kernel: [ 3188.074909] type=1400 audit(1471127319.479:913): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="docker-default" pid=16911 comm="apparmor_parser"
  7. Aug 13 15:28:39 z84302 kernel: [ 3188.148967] init: docker main process (16888) terminated with status 1
  8. Aug 13 15:28:39 z84302 kernel: [ 3188.148996] init: docker main process ended, respawning
  9. Aug 13 15:28:40 z84302 kernel: [ 3189.296377] type=1400 audit(1471127320.699:914): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="docker-default" pid=16960 comm="apparmor_parser"
  10. Aug 13 15:28:40 z84302 kernel: [ 3189.387307] init: docker main process (16937) terminated with status 1
  11. Aug 13 15:28:40 z84302 kernel: [ 3189.387316] init: docker main process ended, respawning
  12.  
  13.  
  14. $ docker images
  15. Cannot connect to the Docker daemon. Is the docker daemon running on this host?
  16.  
  17. $ sudo service docker start
  18. start: Job is already running: docker

I hope that this info helps someone else fix the problem sooner.

Thu, 2016-10-27 17:25
Offline
Joined: 6 months 3 weeks ago

Worked for me!


Just want to thank you for the post, it saved my day!