问题:

在 macOS 编写的一些操作 docker 的脚本,想要不用修改,直接在 Windows cmd 上运行。

解决方案:

  • 安装 bash 

    • scoop install bash 
  • bash -c export DOCKER_HOST=tcp://0.0.0.0:2375&&your-script.sh 

    说明:

    其中 export DOCKER_HOST=tcp://0.0.0.0:2375 很关键,不然会报错:

powershell

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? local-mysql is already killed Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? local-mysql not exist docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See docker run --help.