OpenShift 使用自带registry

获取docker-registry地址

首先需要知道docker-registry 的 route:
#oc get route --all-namespaces|grep registry
docker-registry-default.router.default.svc.cluster.local

添加到insecure-registry列表

默认这个没有在 --insecure-registry列表中,在docker配置文件添加:
/etc/sysconfig/docker
OPTIONS=’ --insecure-registry docker-registry-default.router.default.svc.cluster.local ’

要push镜像到仓库需要先docker login登录,登录密码需要使用token。下面是获取token

获取登录token

使用普通用户登录openshift cli,获取token
#oc login -u cycwll https://master.default.cn:8443
查看用户token
#oc whoami -t
fJ7_d9XRR9OZbuBSR-R0ZValF_E8W6XeT7e4ohCGGFY

登录仓库

docker login docker-registry-default.router.default.svc.cluster.local
username:cycwll
password:(上边获取到的token)

push镜像

先tag镜像,如:
docker tag docker.io/busybox:latest docker-registry-default.router.default.svc.cluster.local/test-project/busybox:latest
docker push docker-registry-default.router.default.svc.cluster.local/test-project/busybox:latest
push镜像之后会自动生成一个imagestream

然后就可以用这个镜像创建application了

你可能感兴趣的:(OpenShift)