Docker-Toolbox常見問題解決方案


Docker Toolbox常見錯誤解決方案

原文:https://docs.docker.com/faqs/troubleshoot/

錯誤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
  • 1

錯誤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.
  • 1
  • 2
  • 3

錯誤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.
  • 1
  • 2
  • 3

這些錯誤可能是由一些常用指令導致,像獲取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
  • 1
  • 2
  • 3

重啟Docker主機

docker-machine restart default
  • 1

將Docker Client連接的默認主機default

 # 設置環境變量: 將default主機作為docker deamon(服務端) eval $(docker-machine env default) # 查看主機列表:default主機Active狀態為'*' docker-machine ls
  • 1
  • 2
  • 3
  • 4

關閉、移除、新建主機

 # 關閉default主機 docker-machine stop default # 移除default主機 docker-machine rm default # 新建主機 docker-machine create --driver virtualbox default
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

使用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
  • 1
  • 2
  • 3
  • 4
  • 5

在虛擬主機中配置代理設置

進入主機

 # 進入default主機 docker-machine ssh default
  • 1
  • 2

編輯配置文件

 # 編輯配置文件:/var/lib/boot2docker/profile docker@default:~$ sudo vi /var/lib/boot2docker/profile
  • 1
  • 2

在配置文件最后添加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.*"
  • 1
  • 2
  • 3
  • 4
  • 5

重啟主機

docker@default:~$ sudo /etc/init.d/docker restart docker@default:~$ exit
  • 1
  • 2

創建虛擬機時直接指定配置

可刪除虛擬機重建

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
  • 1
  • 2
  • 3
  • 4
  • 5


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM