minikube中下载镜像错误Couldn't connect: SOCKS protocol error
- 2019 年 10 月 7 日
- 笔记
问题描述
在启动 minikube 的时候使用的代理环境变量创建的 minikube 虚拟机,但是在下载或者查询镜像的时候会出错,比如下面两个命令都会报相似错误 "Couldn't connect: SOCKS protocol error"
# 在 minikube 虚拟机外执行 $ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080 $ minikube ssh # 在 minikube 虚拟机内执行 $ docker search echoserver Error response from daemon: Get https://index.docker.io/v1/search?q=echoserver&n=25: Couldn't connect: SOCKS protocol error
问题原因
进入 在 minikube 虚拟机内,然后使用 docker info 查看一下 docker 的配置
$ minikube ssh $ docker info Containers: 21 Running: 21 Paused: 0 Stopped: 0 Images: 10 Server Version: 18.09.8 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc version: N/A init version: N/A (expected: ) Security Options: seccomp Profile: default Kernel Version: 4.15.0 Operating System: Buildroot 2018.05.3 OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 1.897GiB Name: minikube ID: I7FY:LMTY:F4SU:NTMU:IJ7Q:FTIB:3UWP:TKLG:42XA:QQOX:JAFD:PV2B Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false HTTP Proxy: http://<host>:<port> HTTPS Proxy: http://<host>:<port> No Proxy: 127.0.0.1/24 Registry: https://index.docker.io/v1/ Labels: provider=virtualbox Experimental: false Insecure Registries: 10.96.0.0/12 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine
其中包含了下面三行,正是自己当时启动 minikube 的时候使用的代理,而这两个代理被 minikube 写入了 docker 的配置文件中。
HTTP Proxy: http://<host>:<port> HTTPS Proxy: http://<host>:<port> No Proxy: 127.0.0.1/24
解决办法
使用 “minikube ssh” 命令登录到虚拟机内,然后修改 Docker 配置文件 /usr/lib/systemd/system/docker.service,这是CentOS7.x上 Docker 配置文件的路径,注释掉上面三行。
#Environment=HTTP_PROXY=http://192.168.0.53:1080 #Environment=HTTPS_PROXY=http://192.168.0.53:1080 #Environment=NO_PROXY=127.0.0.1/24
重新启动服务
$ sudo systemctl daemon-reload $ sudo systemctl restart docker.service
然后重新查询或拉取镜像,问题解决。