kubeflow

kubeflow准备--搭建私有docker仓库

2019-01-06  本文已影响170人  zoux

在很多情况下,我们需要使用自己的docker仓库。接下来是在本地k8s集群上搭建本地仓库的过程。
假设我们将本地仓库搭建在k8s主节点上。
这里假设主节点是:192.168.14.84

1.运行registry镜像

docker run -d -p 5000:5000 --restart always --name registry registry:2
直接运行该命令即可,本地没有registry:2,会自动pull

2.修改配置文件

vim /etc/docker/daemon.json
需要改内容为
{
"insecure-registries": [
"192.168.14.84:5000"
]
}

3.重启docker服务

systemctl restart docker

4.验证是否成功

这里的思想是,先下载一个hello-world的镜像,然后修改标签,然后上传到本地服务器上。然后查看服务器是否有该镜像。

4.1 下载镜像,并打标签

docker pull hello-world
docker tag hello-world:latest 192.168.14.84:5000/hello-world:latest

4.2 将本地的192.168.14.84:5000/hello-world:latest镜像上传服务器:

docker push 192.168.14.84:5000/hello-world

4.3 删除本地的192.168.14.84:5000/hello-world:latest,已经hello-world:latest

docker rmi 192.168.14.84:5000/hello-world:latest
docker rmi hello-world:latest

4.4 然后重新拉取看是否成功

docker pull 192.168.14.84:5000/hello-world

查看本地仓库镜像的命令

curl -X GET http://192.168.14.84:5000/v2/_catalog

PS:

以上都是在master节点做的操作,要想在其他node节点上也能使用本地仓库,需要在其他节点进行步骤2的操作,修改/etc/docker/daemon.json文件。文件内容和上述一样。

上一篇下一篇

猜你喜欢

热点阅读