英文:
Docker on Mac behind proxy that changes ssl certificate
问题
我最终解决下面问题的方法是说服我们的IT人员不要对dockerhub注册表进行中间人攻击。不幸的是,我无法找到其他解决办法。
我在工作中的Mac上遇到了一个问题,即无法成功运行Docker,我的Mac系统版本是10.8.5。似乎是因为公司的证书重写代理阻止了获取镜像:
orflongpmacx8:docker pohl_longsine$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository hello-world
FATA[0001] Get https://index.docker.io/v1/repositories/library/hello-world/images: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "bcauth")
(实际上,当我连接到没有这个干扰代理的访客无线网络时,可以绕过这一步。然而,我需要找出如何通过代理使其工作,因为使用访客无线网络作为长期解决方案是不可行的。)
表面上看,我的问题似乎与这个问题中的问题非常相似。然而,那个问题中被接受的答案对我不起作用,因为他们讨论的root_unix.go文件在Mac上不会被调用。(从浏览周围的内容来看,我猜测可能涉及到root_cgo_darwin.go和/或root_darwin.go。)
这并没有告诉我在操作上如何执行相当于安装某种可信证书的工作。我设法获取了一个*.cer
文件,我相信这就是我需要的文件,但我不知道该怎么处理它。
我希望有人能指点我正确的方向。
**编辑:**我认为也许我需要做类似于这个页面建议的,添加证书。然而,我按照那些说明尝试失败了:
orflongpmacx8:docker pohl_longsine$ sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "~/Desktop/Certs/redacted.cer"
Password:
***Error reading file ~/Desktop/Certs/redacted.cer***
Error reading file ~/Desktop/Certs/redacted.cer
编辑2:我可能离解决问题更近了一步。我应该知道在引号内使用带有波浪符的路径是错误的。如果我使用绝对路径,我可以成功运行上述命令来添加证书。
然而,这并没有解决最终的问题:
FATA[0001] Get https://index.docker.io/v1/repositories/library/hello-world/images: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "bcauth")
英文:
My eventual workaround for the issue below was to convince our IT guys not to man-in-the-middle the dockerhub registry. I was not able to get anything else to work, alas.
I am running into a problem with my initial attempt to get Docker running on my Mac at work, which is running 10.8.5. It appears that my company's certificate-rewriting proxy seems to be getting in the way of fetching images:
orflongpmacx8:docker pohl_longsine$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository hello-world
FATA[0001] Get https://index.docker.io/v1/repositories/library/hello-world/images: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "bcauth")
(Indeed, when I log onto the guest wireless – which does not have the meddlesome proxy – I can get past this step. However, I need to figure out how to make this work through the proxy since using the guest wireless is untenable as a long-term solution.)
My issue, on the surface, appears to be very much like the one answered in this question. However, the accepted answer in that question does not work for me, since the root_unix.go file they discuss does not get invoked on a Mac. (From browsing around, I would guess that root_cgo_darwin.go and/or root_darwin.go would be involved instead.)
That doesn't really tell me how, operationally, I need to do the equivalent work of installing some sort of trusted certificate. I managed to get my hands on a *.cer
file that I believe to be the one that I need, but I'm at a loss as to what to do with it.
I'm hoping that someone can point me in the right direction.
Edit: I thought that maybe I needed to to something akin to what this page suggests, to add the certificate. Alas, my attempt at following those instructions failed in the following way:
orflongpmacx8:docker pohl_longsine$ sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "~/Desktop/Certs/redacted.cer"
Password:
***Error reading file ~/Desktop/Certs/redacted.cer***
Error reading file ~/Desktop/Certs/redacted.cer
Edit 2: I may have come one step closer to solving this. I should have known better to use a path with a tilde inside quotation marks. If I use an absolute path instead, I can successfully run the above command to add certs.
Alas, this did not alleviate the ultimate symptom:
FATA[0001] Get https://index.docker.io/v1/repositories/library/hello-world/images: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "bcauth")
答案1
得分: 7
根据boot2docker的README文件:
不安全的注册表
自Docker版本1.3.1起,如果您的注册表不支持HTTPS,您必须将其添加为不安全的注册表。
$ boot2docker init
$ boot2docker up
$ boot2docker ssh
$ echo 'EXTRA_ARGS="--insecure-registry <YOUR INSECURE HOST>"' | sudo tee -a /var/lib/boot2docker/profile
$ sudo /etc/init.d/docker restart
然后您应该能够执行docker push/pull操作。
英文:
According to the boot2docker README
Insecure Registry
As of Docker version 1.3.1, if your registry doesn't support HTTPS, you must add it as an insecure registry.
$ boot2docker init
$ boot2docker up
$ boot2docker ssh
$ echo 'EXTRA_ARGS="--insecure-registry <YOUR INSECURE HOST>"' | sudo tee -a /var/lib/boot2docker/profile
$ sudo /etc/init.d/docker restart
then you should be able to do a docker push/pull.
答案2
得分: 4
http://golang.org/src/crypto/x509/root_darwin.go的源代码显示,使用以下命令来查找证书:
cmd := exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", "/System/Library/Keychains/SystemRootCertificates.keychain")
尝试将.cer
文件添加到OSX证书钥匙串中。
英文:
The source of http://golang.org/src/crypto/x509/root_darwin.go shows that the command:
cmd := exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", "/System/Library/Keychains/SystemRootCertificates.keychain")
is used to find the certificate.
Try adding the .cer
file into the OSX certificate key-chain.
答案3
得分: 0
如果你使用docker-machine,编辑$USER/.docker/machine/machines/default/config.json文件:
"EngineOptions": {
"InsecureRegistry": [
"XXX.XXX.virtual"
],
}
英文:
If you use the docker-machine
edit $USER/.docker/machine/machines/default/config.json
"EngineOptions": {
"InsecureRegistry": [
"XXX.XXX.virtual"
],
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论