如何在Windows上忽略Boot2Docker中的证书错误
我有boot2docker 1.4.1通过virtualbox在Windows上运行。 我在一个代理MITMs https证书的背后。 我通过在/var/lib/boot2docker/profile
添加以下行来configuration代理:
export HTTP_PROXY=<proxyhost>:80 export HTTPS_PROXY=<proxyhost>:80 DOCKER_TLS=no EXTRA_ARGS="--insecure-registry index.docker.io"
但是当我运行docker@boot2docker:~$ docker run hello-world
我得到
Unable to find image 'hello-world:latest' locally Pulling repository hello-world FATA[0006] Get https://index.docker.io/v1/repositories/library/hello-world/images : x509: certificate signed by unknown authority
请帮我找出忽略证书错误的正确方法。 谢谢!
编辑看起来像新的docker只适用于某些特定的Windows 10 。 如果你仍然被困在Windows 7上,我已经更新了下面的内容,以反映当我安装最新版本的docker-toolbox( Docker 1.11.2)时,为了纠正“证书链中的自签名证书”错误)。
最后得到这个工作在Windows 7的答案在这里: https : //github.com/boot2docker/boot2docker/issues/347
通过运行openssl s_client -showcerts来检查这是你的问题:
docker@boot2docker:~$ openssl s_client -showcerts -CApath . -connect index.docker.io:443
(编辑:从-showcerts中删除32并更正主机名)
在证书链中,你会看到代理已经插入自己,validation返回一个类似这样的错误
Verify return code: 19 (self signed certificate in certificate chain)
如果您遇到同样的问题,请尝试以下步骤:
- 首先,保存你需要的证书。 以下是在Firefox中使用的步骤,类似于https://stackoverflow.com/a/6966818/1981358(Chrome和IE也应该使用证书导出向导;注意:在Windows上,PEM证书编码称为Base-64编码X.509(.CER)):
- 在Firefox中,转到https://hub.docker.com/
- 点击地址栏上的锁图标显示证书
- 点击“更多信息” – >“安全” – >“查看证书” – >“详细信息”
- 从最上面的层次结构中select层次结构中的每个节点,然后单击“导出”和“保存”(selectX.509证书(PEM)格式)
- 将上述文件保存在本地驱动器的某个位置,将扩展名更改为.pem,并将它们移动到您的用户文件夹(或其他可从ssh访问的位置)
- 创build一个文件夹来保存证书:
docker@boot2docker:~$ sudo mkdir /var/lib/boot2docker/certs/
- 将证书文件复制到该位置:
docker@boot2docker:~$ sudo cp /c/Users/<username>/<folder>/<proxy-cert>.pem /var/lib/boot2docker/certs/
- 创build文件
/var/lib/boot2docker/bootlocal.sh
并包含来自https://gist.github.com/irgeek/afb2e05775fff532f960 (我刚刚在Windows中使用记事本++创build的文件,并将其复制到正确的位置类似于上述步骤) - 退出ssh并重新启动:
C:\>docker-machine restart
- 打开shell
docker-machine ssh
并validationdocker run hello-world
的更改:docker run hello-world
你应该看到包含如下内容的输出:
Hello from Docker. This message shows that your installation appears to be working correctly.
如果你在Windows 10上有适用于Windows的 Docker ,并且你得到了“x509:由未知权限签名的证书”错误,你可以试试这个:
- 运行Docker for Windows。
- 过了一段时间,您会在Windows通知区域(右下angular)看到docker图标,
- 右键点击图标并select“设置…”
- 设置窗口将打开。 select左边的“Docker Daemon”。
- 将您的私有registry添加到以JSON格式显示configuration的文本框中的“insecure-registries”集合。 然后点击“应用”。