DockerHub镜像仓库:
https://hub.docker.com/html
google镜像仓库:
https://gcr.io/google-containers/
https://gcr.io/kubernetes-helm/
https://gcr.io/google-containers/pauselinux
coreos镜像仓库:
https://quay.io/repository/nginx
elastic镜像仓库:
https://www.docker.elastic.co/git
RedHat镜像仓库:
https://access.redhat.com/containersgithub
阿里云镜像仓库:
https://cr.console.aliyun.comweb
华为云镜像仓库:
https://console.huaweicloud.com/swrdocker
部分国外镜像仓库没法访问,但国内有对应镜像源,能够从如下镜像源拉取到本地而后重改tag便可:
阿里云镜像仓库shell
能够拉取k8s.gcr.io镜像json
#示例 docker pull k8s.gcr.io/pause:3.2 #改成 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2
dockerhub镜像仓库windows
能够拉取k8s.gcr.io镜像
#示例 docker pull k8s.gcr.io/pause:3.1 docker pull k8s.gcr.io/kube-apiserver:v1.17.3 #改成 docker pull googlecontainersmirrors/pause:3.1 docker pull googlecontainersmirrors/kube-apiserver:v1.17.3
七牛云镜像仓库
能够拉取quay.io镜像
#示例 docker pull quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0 #改成 docker pull quay-mirror.qiniu.com/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0
dockerhub搜索镜像
不少国外镜像已经有热心网友传到了dockerhub,例如gcr.io/kubernetes-helm/tiller:v2.16.5这个镜像,直接搜索关键字,找到排序靠前的而后在dockerhub确认并拉取便可:
# docker search tiller NAME DESCRIPTION STARS OFFICIAL AUTOMATED jessestuart/tiller Nightly multi-architecture (amd64, arm64, ar 19 [OK] sapcc/tiller Mirror of https://gcr.io/kubernetes-helm/til 9 ist0ne/tiller https://gcr.io/kubernetes-helm/tiller ....
阿里云镜像加速
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://uyah70su.mirror.aliyuncs.com"] } EOF
daocloud dockerhub镜像加速
https://www.daocloud.io/mirror
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
西北农林大学dockerhub镜像加速
https://mirrors.nwafu.edu.cn/help/reverse-proxy/dockerhub
{ "registry-mirrors": ["https://dockerhub.mirrors.nwafu.edu.cn/"] }
华为云dockerhub镜像加速
https://console.huaweicloud.com/swr
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<- 'EOF' { "registry-mirrors": ["https://7bafc985f90c43b887a96c2b846cf984.mirror.swr.myhuaweicloud.com"] } EOF
而后从新启动 Docker 服务:
sudo systemctl daemon-reload && sudo systemctl restart docker
验证加速器是否生效
执行 $ docker info,若是从结果中看到了以下内容,说明配置成功。
$ docker info | grep Mirrors -A1 Registry Mirrors: https://uyah70su.mirror.aliyuncs.com/ #验证镜像拉取速度 $ time docker pull centos
若是你已经在本地windows上使用番茄工具,默承认以经过它的1080端口来拉取镜像。
在安装docker的linux服务器执行如下操做,其中192.168.0.103是你本地windows能上网的网卡IP:
mkidr -p /etc/systemd/system/docker.service.d cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF [Service] Environment="HTTP_PROXY=http://192.168.0.103:1080" EOF systemctl daemon-reload && systemctl restart docker
注意还要在客户端里鼠标右键勾选容许其余设备链接。以上配置完成后便可直接拉取google镜像
# docker pull k8s.gcr.io/kube-apiserver:v1.16.1 v1.16.1: Pulling from kube-apiserver 39fafc05754f: Already exists 010af2aa5529: Pull complete Digest: sha256:80feeaed6c6445ab0ea0c27153354c3cac19b8b028d9b14fc134f947e716e25e Status: Downloaded newer image for k8s.gcr.io/kube-apiserver:v1.16.1 k8s.gcr.io/kube-apiserver:v1.16.1
咱们也能够在dockerhub或阿里云建立我的仓库,把须要的最新版本镜像从google仓库push到我的仓库,通常有几下几种方法:
1.购买云服务器
购买1台能同时访问国外和国内网络的云服务器,使用docker login登陆dockerhub或阿里云仓库,docker push命令推送上去而后再拉取到本地便可。
若是不想购买服务器又可以访问国外网络,建议使用google提供的cloud shell:
https://console.cloud.google.com/cloudshell
它相似一个永久免费的拥有5G存储空间的linux服务器,可以执行全部docker命令和bash命令,最重要的是它可以访问全球网络。
2.Travis CI推送镜像
使用travis CI+GitHub将镜像push到国内镜像仓库。
3.Github镜像构建功能
使用github的dockerfile构建功能,将镜像构建到国内仓库。
参考:https://blog.csdn.net/networken/article/details/85215714
下面介绍第2种方法,使用travis CI+GitHub的方法将镜像拉取到阿里云或者dockehub。
建立github仓库
首先登陆github建立一个仓库,名称自定义,仓库包含以下2个文件:
示例仓库:https://github.com/willzhang/pull-docker-images
.travis.yaml 内容以下,主要从国外镜像仓库pull镜像,打tag,并push到阿里云或dockerhub.
language: bash services: - docker env: global: #change the registry name and username/password to yourself's. - DOCKER_HUB=willdockerhub - ALI_REGISTRY=registry.cn-shenzhen.aliyuncs.com/images_mirror before_script: - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - docker login $ALI_REGISTRY -u $ALI_USERNAME -p $ALI_PASSWORD script: - echo "start pull and retag and push" - | for image in $(cat img-list.txt) do image_name=${image##*/} docker pull $image docker tag $image $DOCKER_HUB/$image_name docker tag $image $ALI_REGISTRY/$image_name # push到dockerhub docker push $DOCKER_HUB/$image_name # push到阿里云仓库 docker push $ALI_REGISTRY/$image_name done
img-list.txt主要包含国内没法拉取的镜像列表,注意必须为完整镜像路径和名称,示例以下:
gcr.io/google-containers/kube-apiserver-amd64:v1.12.0 quay.io/external_storage/nfs-client-provisioner:latest
.travis.yaml文件监测github仓库的代码变更,当有代码变更时好比img-list.txt写入新的镜像列表时将触发tarvis的自动构建
这里须要登陆阿里云或dockerhub才能执行docker push操做,其中$ALI_USERNAME这类变量在TravisCI管理界面定义好便可。
TravisCI配置
访问travis官网: https://www.travis-ci.com, 使用github帐号登陆。
开启须要进行自动化构建的仓库便可:
另外须要点击右上角的more options —》settings选项,定义写在.travis.yaml中的帐号密码等敏感参数。
当对github仓库执行git commit、git push操做时将自动触发构建,执行仓库中的脚本,这里的构建结果以下:
登陆阿里云或dockerhub查看,imagepath.txt 列表中的镜像已经成功被push上来:
注意:push到阿里云的镜像默认为私有的,能够手动改成公开的。
平常拉取镜像方法:
修改img-list.txt,写入须要拉取的镜像完整路径,保存后travis-CI监测到仓库代码变更,自动触发构建,几分钟后镜像就会被自动拉取到我的仓库。
参考: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy https://blog.csdn.net/nklinsirui/article/details/80581286 https://www.cnblogs.com/xuxinkun/p/11025020.html