錯誤1
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": dial tcp 192.168.99.100:2376: i/o timeout
錯誤2
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": x509: certificate is valid for 192.168.99.101, not 192.168.99.100 You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. Be advised that this will trigger a Docker daemon restart which will stop running containers.
錯誤3
Unable to find image 'hello-world:latest' locally Pulling repository docker.io/library/hello-world Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy.
這些錯誤可能是由一些常用指令導致,像獲取default主機的環境變量docker-machine env default
連接主機獲取環境變量,
或者拉取鏡像運行容器的指令docker run hello-world
。
問題出現突然,而且不穩定。以下介紹幾種通用的解決方案。(以下以default主機為例)
重新生成證書
$ docker-machine regenerate-certs default Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y Regenerating TLS certificates
重啟Docker主機
docker-machine restart default
將Docker Client連接的默認主機default
# 設置環境變量: 將default主機作為docker deamon(服務端) eval $(docker-machine env default) # 查看主機列表:default主機Active狀態為'*' docker-machine ls
關閉、移除、新建主機
# 關閉default主機 docker-machine stop default # 移除default主機 docker-machine rm default # 新建主機 docker-machine create --driver virtualbox default
使用HTTP代理出現的連接錯誤
通常在VPN網絡環境中使用HTTP proxy時,用Docker Toolbox連接服務端會出錯。
$ docker run hello-world An error occurred trying to connect: Post https://192.168.99.100:2376/v1.20/containers/create: Forbidden $ docker run ubuntu echo "hi" An error occurred trying to connect: Post https://192.168.99.100:2376/v1.20/containers/create: Forbidden
在虛擬主機中配置代理設置
進入主機
# 進入default主機 docker-machine ssh default
編輯配置文件
# 編輯配置文件:/var/lib/boot2docker/profile docker@default:~$ sudo vi /var/lib/boot2docker/profile
在配置文件最后添加NO_PROXY配置,配置文件內容如下:
# replace with your office's proxy environment
export "HTTP_PROXY=http://PROXY:PORT"
export "HTTPS_PROXY=http://PROXY:PORT"
# you can add more no_proxy with your environment.
export "NO_PROXY=192.168.99.*,*.local,169.254/16,*.example.com,192.168.59.*"
重啟主機
docker@default:~$ sudo /etc/init.d/docker restart docker@default:~$ exit
創建虛擬機時直接指定配置
可刪除虛擬機重建
docker-machine create -d virtualbox \ --engine-env HTTP_PROXY=http://example.com:8080 \ --engine-env HTTPS_PROXY=https://example.com:8080 \ --engine-env NO_PROXY=example2.com \ default