gpt4 book ai didi

windows - 计算机 sleep 后无法访问 Docker

转载 作者:IT老高 更新时间:2023-10-28 12:44:47 32 4
gpt4 key购买 nike

我刚刚使用 docker-toolbox 1.8.2 安装了 docker在 Windows 10 上。

由于由于this issue我不得不使用这些命令重新创建 docker 镜像

docker-machine rm default
docker-machine --native-ssh create -d virtualbox default

之后它一直工作正常,除了一个问题:

当 PC 进入休眠状态然后再次唤醒时,docker 命令无法再连接。示例:

> docker images
An error occurred trying to connect: Get https://192.168.99.100:2376/v1.20/images/json:
dial tcp 192.168.99.100:2376: ConnectEx tcp: A connection attempt failed because the
connected party did not properly respond after a period of time, or established connection
failed because connected host has failed to respond.

但是 docker-machine 将机器列为正在运行:

> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
default * virtualbox Running tcp://192.168.99.100:2376

我还可以在 VirtualBox 中确认 VM 屏幕似乎处于事件状态。

我试过启动和停止机器,但没有帮助

C:\x> docker-machine stop default
C:\x> docker-machine start default
Starting VM...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
C:\x> docker-machine env default --shell=powershell

具有讽刺意味的是,最后一个命令挂起,所以我从来没有得到任何环境设置。

唯一有用的是重新启动整个 PC。但这应该是不必要的吧?

我也将其发布为 an issue on the docker github repository ,但那是关闭的。 A related issue seems to be this one ,但尚未发布适用于 Windows 的解决方法或解决方案。

最佳答案

经过与 VirtualBox + Docker Toolbox 的斗争,我终于找到了方法,如何让 Docker 再次工作(即使不重新启动所有容器):

  1. 从 sleep 中唤醒电脑
  2. 尝试 docker images(不会工作)
  3. 打开 VirtualBox -> 以保存状态关闭虚拟机 (CTRL+V)
  4. 再次运行您的虚拟机
  5. 再次尝试 docker images(现在应该可以了)

请注意:所有步骤仅在 VirtualBox 中!运行 docker-machine restart default 将创建另一个仅主机适配器,这是您不想要的。如果您还是这样做了,请删除所有额外创建的适配器(文件->首选项->VirtualBox 上的网络),然后按照步骤 1-5 操作。

关于windows - 计算机 sleep 后无法访问 Docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32547427/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com