Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafaeltuelho/19b330038b39e4939031d7ff474ae546 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/19b330038b39e4939031d7ff474ae546 to your computer and use it in GitHub Desktop.
Pushing to an OpenShift registry

How to setup an OpenShift registry

  • Create registry with oadm
oadm registry --latest-images --create \
              --credentials=/var/lib/openshift/openshift.local.config/master/openshift-registry.kubeconfig
  • Create route (optional, alternatively you can use also the internal ip of the registry service later)
cat <<EOF | oc create -f -
{
    "kind": "Route",
    "apiVersion": "v1",
    "metadata": {
        "name": "docker-registry-route"
    },
    "spec": {
        "host": "docker-registry.vagrant.f8",
        "to": {
            "kind": "Service",
            "name": "docker-registry"
        }
    }
}
EOF
  • Create image
docker build . -t docker-registry.vagrant.f8:80/foo/test
  • Add an OpenShift project with username part of your image
oc new-project foo
  • Login in to docker with a use which has access to the created project 'foo'
docker login -u admin -p $(oc whoami -t) docker-registry.vagrant.f8:80
  • Push
docker push docker-registry.vagrant.f8:80/foo/test

See also the OpenShift Documentation

Note: to be able to access/login an OSE registry from an external host (outside the Openshift cluster nodes) you have to import the Openshift CA certificate. The openshift CA certificate can be found at /etc/docker/certs.d/<your public registry route url>/ca.crt. copy this ca.crt into your host's file system at /etc/docker/certs.d//etc/docker/certs.d/<your public registry route url>/ca.crt/ca.crt. restart your docker engine daemon: sudo systemctl restart docker now you can login into your Openshift remote registry: docker login -u admin -p $(oc whoami -t) http://<your public registry route url>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment