GUI Free Life View on GitHub

How to push an image to an unexposed OpenShift Docker registry

openshift docker

Aug 09, 2017

How do I push an image to the OpenShift Docker registry if it is not exposed outside the cluster?

Login to a member node

Get on a machine that has docker and participates in the cluster SDN or can somehow access that network. (eg. 172.30.0.0/16)

Get the IP of the registry

oc get svc docker-registry -n default --template "{{ .spec.clusterIP }}"
SVC_REGISTRY=$(oc get svc docker-registry -n default --template "{{ .spec.clusterIP }}")

Get a token for your session

oc whoami -t
r4bjk9MrFcWz8SjR688zvbAbwnI1yoqNbtdhN1sMaeo
TOKEN=$(oc whoami -t)

Login to the docker registry

docker login -u $(oc whoami) -p $TOKEN  $SVC_REGISTRY:5000

Commit the container and / or tag the image

docker commit <container_id> $SVC_REGISTRY:5000/project/image:tag

Push the tagged image

docker push $SVC_REGISTRY:5000/project/image:tag

See Also