简体   繁体   English

如何为Windows配置Docker以使用主机文件推送到存储库

[英]How to configure Docker for windows to push using hosts file for repository

I'm trying to push a container from my local dev box to a remote private repository whose hostname is set in my Windows host file. 我正在尝试将容器从本地开发箱推送到其主机名在Windows主机文件中设置的远程专用存储库。 When I push I get this: 当我推动时,我得到以下信息:

docker push docker:5000/m2
The push refers to a repository [docker:5000/m2]
Put http://docker:5000/v1/repositories/m2/: dial tcp: lookup docker on 192.168.65.1:53: no such host

If I do a curl -vvv on the URL using babun I get this: 如果我使用babun对URL进行curl -vvv,则会得到以下信息:

curl -vvv http://docker:5000/v1/repositories/m2/
* STATE: INIT => CONNECT handle 0x20048188; line 1034 (connection #-5000)
* Added connection 0. The cache now contains 1 members
*   Trying 192.168.1.8...
* STATE: CONNECT => WAITCONNECT handle 0x20048188; line 1087 (connection #0)
* Connected to docker (192.168.1.8) port 5000 (#0)
* STATE: WAITCONNECT => DO handle 0x20048188; line 1229 (connection #0)
> GET /v1/repositories/m2/ HTTP/1.1
> User-Agent: Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))
> Host: docker:5000
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x20048188; line 1314 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x20048188; line 1441 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x20048188; line 1454 (connection #0)
* Increasing bytecount by 7 from hbuflen

* nread <= 0, server closed connection, bailing
* STATE: PERFORM => DONE handle 0x20048188; line 1626 (connection #0)
* Connection #0 to host docker left intact
* Expire cleared

Since I'm getting the error message locally, but not when I use curl, and given the error message, it seems like my local Windows docker instance is not resolving to the docker hostname. 由于我在本地获取错误消息,但是当我使用curl时却没有,并且给出错误消息,因此我的本地Windows docker实例似乎未解析为docker主机名。

Docker does the push on the remote docker daemon, not the local docker client, which means the DNS resolution needs to work on that system. Docker在远程docker守护程序而不是本地docker客户端上进行推送,这意味着DNS解析需要在该系统上工作。 This also includes any proxy settings. 这也包括任何代理设置。 There was also a recent bug that at least affected Docker for Mac, possibly also Windows too, where it was not using the local DNS server. 最近还存在一个漏洞,至少在不使用本地DNS服务器的情况下,该漏洞至少影响了Mac版的Docker for Mac(可能还有Windows)。 I believe that's been fixed in 1.13.1, but I already worked around that by adding the entries I needed into the /etc/hosts file (I believe windows still puts this under system32\\drivers\\etc). 我相信该问题已在1.13.1中修复,但我已经通过在/ etc / hosts文件中添加所需的条目来解决此问题(我相信Windows仍将其放在system32 \\ drivers \\ etc下)。

Note that after you change DNS settings on the Windows host to get name resolution working, you'll likely need to restart the docker daemon to get the embedded VM to restart with these changes. 请注意,在Windows主机上更改DNS设置以使名称解析正常工作后,您可能需要重新启动docker守护程序,以使嵌入式VM随这些更改而重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM