[英]Use https for accessing Docker private registry
我有一個私人注冊表,它可以通過https協議訪問。 但是Kubernetes + Docker總是嘗試使用http協議http://myserver.com:8080而不是https://myserver.com:8080 。
如何強制https協議?
我的yaml
文件的片段聲明了一個Pod:
containers:
- name: apl
image: myserver.com:8080/myimage
我的環境細節:
Kubernetes日志中的錯誤消息:
Normal Pulling 30s (x4 over 2m2s) kubelet, minikube pulling image "docker.mydomain.com:30500/vision-ssh"
Warning Failed 30s (x4 over 2m2s) kubelet, minikube Failed to pull image "docker.mydomain.com:30500/vision-ssh": rpc error: code = Unknown desc = Error response from daemon: Get http://docker.mydomain.com:30500/v2/: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02"
Warning Failed 30s (x4 over 2m2s) kubelet, minikube Error: ErrImagePull
Warning Failed 19s (x6 over 2m2s) kubelet, minikube Error: ImagePullBackOff
Normal BackOff 4s (x7 over 2m2s) kubelet, minikube Back-off pulling image "docker.fccma.com:30500/vision-ssh"
如果我嘗試在圖像名稱中指定協議,它會抱怨:
couldn't parse image reference "https://docker.mydomain.com:30500/vision-ssh": invalid reference format
按照本指南進行操作以創建映像注冊表。 它已經安全(HTTPS協議並受用戶/密碼保護)。
在/etc/hosts
文件中,服務器docker.mydomain.com
映射到127.0.0.1。 我在docker docs中讀過,本地注冊表總是被認為是不安全的。 如果我使用映射到外部IP的名稱,則Docker會嘗試https
。
您的私人碼頭注冊表可能不受保護。 如果它是安全的私人注冊表,它總是使用https,否則它引用http。
有關詳細信息,請參閱doc:
Docker uses the https:// protocol to communicate with a registry, unless the registry is allowed to be accessed over an insecure connection. Refer to the insecure registries section for more information.
https://docs.docker.com/engine/reference/commandline/dockerd/#insecure-registries
因此,要強制https,請保護您的注冊表。 網上有很多文章可以保護您的注冊表。
運行容器注冊表服務前面的https代理服務。 將nginx看作https代理
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.