Docker Desktop突然无法使用的问题解决办法

1,219 阅读5分钟

默认安装的docker desktop是没有勾选wsl的,这种情况下,直接使用power shell或者cmd执行docker ps都会报超时。

最好的先用梯子,在jetBrain的services窗口,连接docker后,在images那执行docker pull,这样就可以拉取镜像了!

遇到的问题:清理了一下电脑,原本没问题的docker desktop无法使用了

鼓捣半天后无论执行什么命令都是下面问题

win10 docker报错  error during connect: Get https://192.168.99.100:2376和Error checking TLS connection

无论执行什么命令都报错连接超时

C:\Windows\system32> docker images
error during connect: Get "http://192.168.99.100:2376/v1.24/images/json": 
dial tcp 192.168.99.100:2376: connectex: 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安装目录下执行以下命令

C:\Program Files\Docker\Docker> .\DockerCli.exe -SwitchDaemon

然后事项docker-machine

PS C:\Program Files\Docker\Docker> docker-machine
Usage: docker-machine.exe [OPTIONS] COMMAND [arg...]

Create and manage machines running Docker.

Version: 0.14.0, build 89b8332

Author:
  Docker Machine Contributors - <https://github.com/docker/machine>

Options:
  --debug, -D                                                   Enable debug mode
  --storage-path, -s "C:\Users\Administrator\.docker\machine"   Configures storage path [$MACHINE_STORAGE_PATH]
  --tls-ca-cert                                                 CA to verify remotes against [$MACHINE_TLS_CA_CERT]
  --tls-ca-key                                                  Private key to generate certificates [$MACHINE_TLS_CA_KEY]
  --tls-client-cert                                             Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT]
  --tls-client-key                                              Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY]
  --github-api-token                                            Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN]
  --native-ssh                                                  Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH]
  --bugsnag-api-token                                           BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN]
  --help, -h                                                    show help
  --version, -v                                                 print the version

Commands:
  active                Print which machine is active
  config                Print the connection config for machine
  create                Create a machine
  env                   Display the commands to set up the environment for the Docker client
  inspect               Inspect information about a machine
  ip                    Get the IP address of a machine
  kill                  Kill a machine
  ls                    List machines
  provision             Re-provision existing machines
  regenerate-certs      Regenerate TLS Certificates for a machine
  restart               Restart a machine
  rm                    Remove a machine
  ssh                   Log into or run a command on a machine with SSH.
  scp                   Copy files between machines
  mount                 Mount or unmount a directory from a machine with SSHFS.
  start                 Start a machine
  status                Get the status of a machine
  stop                  Stop a machine
  upgrade               Upgrade a machine to the latest version of Docker
  url                   Get the URL of a machine
  version               Show the Docker Machine version or a machine docker version
  help                  Shows a list of commands or help for one command

如果没有docker-machine请安装

如果遇到找不到C:\Users\Administrator\.docker\machine\certs\ca.pem

请执行以下命令docker-machine --debug regenerate-certs -f default

PS C:\Program Files\Docker\Docker> docker-machine --debug regenerate-certs -f default
Docker Machine Version:  0.14.0, build 89b8332
Regenerating TLS certificates
Docker machine "default" does not exist. Use "docker-machine ls" to list machines. Use "docker-machine create" to add a new one.

如果连default都不存在请执行

PS C:\Program Files\Docker\Docker> docker-machine ls
NAME   ACTIVE   DRIVER   STATE   URL   SWARM   DOCKER   ERRORS

PS C:\Program Files\Docker\Docker> docker-machine create default --virtualbox-no-vtx-check
Running pre-create checks...
(default) Image cache directory does not exist, creating it at C:\Users\Administrator\.docker\machine\cache...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v19.03.12
(default) Downloading C:\Users\Administrator\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso..

这里如果boot2docker.iso迟迟下载不了

请使用梯子和迅雷等快速下载后,放入C:\Users\Administrator\.docker\machine\cache目录

然后再执行docker-machine create default --virtualbox-no-vtx-check

出现下面内容

PS C:\Program Files\Docker\Docker> docker-machine create default --virtualbox-no-vtx-check
Running pre-create checks...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v19.03.12
(default) Downloading C:\Users\Administrator\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso...
Error with pre-create check: "Get https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso: dial tcp 20.205.243.166:443: connectex: 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."
PS C:\Program Files\Docker\Docker> docker-machine create default --virtualbox-no-vtx-check
Running pre-create checks...
(default) Unable to get the latest Boot2Docker ISO release version:  Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 20.205.243.168:443: connectex: 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.
Creating machine...
(default) Copying C:\Users\Administrator\.docker\machine\cache\boot2docker.iso to C:\Users\Administrator\.docker\machine\machines\default\boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(default) Waiting for an IP...



//第一步
docker-machine --debug regenerate-certs -f default
//第二步
docker-machine --debug env default
//第三步
docker-machine start
//第四步
docker-machine -D ssh default

然后再执行docker-machine --debug regenerate-certs -f default创建证书

创建成功后,在电脑环境变量添加

然而,这并没有什么卵用!直接跳过行不行?

还是无法拉取镜像

实在是没法了,研究了一下WSL

在win10上安装了ubuntu

默认都是stoped

通过wsl -d Ubunut-xxx 进入ubuntu,就会自动启动为running

然后在docker desktop 勾选Use the WSL 2 based engine,wsl 后两项也会running

然后直接进入ubuntu,登录阿里云镜像仓库,拉取自己上传的镜像

拉取成功后

docker desktop 就有对应的镜像了

重新tag一下阿里云的镜像,然后就可以通过JetBrain的工具直接启动容器了

到此,总算把windows10这个docker desktop的怪问题跳过了