是否可以将公共docker映像存储在私有docker注册表中

时间:2018-07-12 03:07:52

标签: docker kubernetes

对于公司规则,我们的VM无法访问Internet(也不能使用http代理)。我通过下载rpm包和docker镜像来安装kubernetes集群,如下所示:

RewriteBase /

然后我安装rpm软件包并将这些docker映像加载到所有VM中。尽管辛苦了,但它可以成功安装kubernetes。

我的问题是,我可以使用私有Docker注册表来存储这些k8s.gcr.io,quay.io和其他公共注册表的映像,而每个VM的docker.service可以像我的私有映像一样提取这些映像吗?

2 个答案:

答案 0 :(得分:4)

有几种解决方案:

  1. 由于您的计算机没有互联网连接,并且您要使用相同的图像名称-您需要为其提供互联网。可以使用任何squid之类的代理服务器来完成。在这种情况下,您需要重新配置docker使其在代理之后工作
  2. 部署任何本地注册表解决方案(例如Artifactory),然后将其用作docker的镜像

P.S:我并非坚持使用Artifactory,但这可能非常方便。您看,Artifactory提供了创建虚拟注册表的功能。您可以在此虚拟注册表下聚集其他注册表(k8s.gcr.io,quay.io,等等),然后将其用于docker镜像。

答案 1 :(得分:1)

是的,只要您有一台同时连接到公共仓库和私有仓库的计算机,您就应该能够做到。您可以从公共场所拉下图像,对其进行标记,然后使用docker push将其推送到您的存储库。来自https://blog.docker.com/2013/07/how-to-use-your-own-registry/

的ubuntu
# First, make sure you have the "ubuntu" repository:
docker pull ubuntu

# Then, find the image id that corresponds to the ubuntu repository
docker images | grep ubuntu | grep latest
ubuntu  latest  8dbd9e392a96  12 weeks ago  263 MB (virtual 263 MB)

# Almost there!
# Tag to create a repository with the full registry location.
# The location becomes a permanent part of the repository name.
docker tag 8dbd9e392a96 localhost.localdomain:5000/ubuntu

# Finally, push the new repository to its home location.
docker push localhost.localdomain:5000/ubuntu