MacOs docker异常 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  • 问题描述:
    mac异常重启后,发现docker无法正常工作,具体表现

    • docker-desktop打开无反应,顶部不会出现小鲸鱼图标
    • 执行一些docker相关的命令会报错:
      Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
      
  • 解决办法:卸载重装docker-desktop

    • step1.0: 在折腾的过程中参照菜鸟教程的案例通过$ brew install --cask --appdir=/Applications docker安装过docker,所以此处我brew卸载一下以防有残留, 如果之前没有使用brew安装的可跳过
      # 卸载docker, 在折腾之前
      brew uninstall --cask docker
      
    • step1.1: 卸载docker-desktop, 参照官方github uninstall.sh脚本
      #!/bin/bash
      
      # Uninstall Script
      
      if [ "${USER}" != "root" ]; then
      	echo "$0 must be run as root!"
      	exit 2
      fi
      
      while true; do
        read -p "Remove all Docker Machine VMs? (Y/N): " yn
        case $yn in
          [Yy]* ) docker-machine rm -f $(docker-machine ls -q); break;;
          [Nn]* ) break;;
          * ) echo "Please answer yes or no."; exit 1;;
        esac
      done
      
      echo "Removing Applications..."
      rm -rf /Applications/Docker.app
      
      echo "Removing docker binaries..."
      rm -f /usr/local/bin/docker
      rm -f /usr/local/bin/docker-machine
      rm -r /usr/local/bin/docker-machine-driver*
      rm -f /usr/local/bin/docker-compose
      
      echo "Removing boot2docker.iso"
      rm -rf /usr/local/share/boot2docker
      
      echo "Forget packages"
      pkgutil --forget io.docker.pkg.docker
      pkgutil --forget io.docker.pkg.dockercompose
      pkgutil --forget io.docker.pkg.dockermachine
      pkgutil --forget io.boot2dockeriso.pkg.boot2dockeriso
      
      echo "All Done!"
      
    • step2.1: 安装docker, 下载 Docker.dmg, 安装之
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐