Unable to push a docker image to local OpenShift Origin registry

二次信任 提交于 2019-12-05 05:57:01

You can, like Graham pointed out above expose the registry, but it's not required.

In your case when using internal IP, the docker push command docker push 172.30.1.1:5000/alpine:latest is not correct. In either case (external route or internal IP) the internal registry, based on the image namespace and name, will create appropriate image stream for you. The name of the image stream and the namespace/project for it, is taken from the push. This means you need to make sure you tag the image with 3 elements:

  • docker registry IP and port (external route or internal IP)
  • namespace/project your user have access to (in case of oc cluster up myproject is the default one your user have access to)
  • finally the image stream name

In your case the docker push should look like this: docker push 172.30.1.1:5000/myproject/alpine:latest.

There are potentially a couple of issues which can affect when trying to push docker images.

Before we get to that, usually the way to give access to the internal image registry would be to expose it using a route. Since using an IP as you were only applies to oc cluster up, will show how to use a route instead, that way more generic.

For oc cluster up, you would run:

oc expose svc/docker-registry -n default --as system:admin

This would create a URL for the internal image registry of:

http://docker-registry-default.127.0.0.1.nip.io/

Next login to the internal image registry using:

docker login -u developer -p `oc whoami -t` http://docker-registry-default.127.0.0.1.nip.io:80/

Make sure you use :80 in the URL when you login. If the internal image registry was exposed using a secure route, would instead use :443 instead of :80.

Next you want to tag the image, but do be careful what you tag it with, as you want to include the project name in which the image stream should be added.

docker tag alpine:latest docker-registry-default.127.0.0.1.nip.io:80/myproject/alpine

See how I included myproject in tag, as that is the project I wanted it to end up in.

Details in:

Again use :80 for the port in the name. That need the port in the URL when logging in, even though http given, may be a bug in 3.6.0 or docker command line client. They mention this against OpenShift Online at the moment, which is using 3.6.0.

Now can push the image:

docker push docker-registry-default.127.0.0.1.nip.io:80/myproject/alpine

Full sequence of commands is:

$ oc expose svc/docker-registry -n default --as system:admin
route "docker-registry" exposed

$ docker login -u developer -p `oc whoami -t` http://docker-registry-default.127.0.0.1.nip.io:80/
Login Succeeded

$ docker tag alpine:latest docker-registry-default.127.0.0.1.nip.io:80/myproject/alpine

$ docker push docker-registry-default.127.0.0.1.nip.io:80/myproject/alpine
The push refers to a repository [docker-registry-default.127.0.0.1.nip.io:80/myproject/alpine]
5bef08742407: Layer already exists
latest: digest: sha256:471fd6e70d36b9c221f76464d0a9ff78392ccee359da351ebfec45138fb40f9b size: 528

$ oc get is
NAME      DOCKER REPO                        TAGS      UPDATED
alpine    172.30.1.1:5000/myproject/alpine   latest    10 seconds ago
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!