Skip to content

Instantly share code, notes, and snippets.

@rhuss
Last active September 24, 2021 16:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rhuss/1015bf1ffa6bedcd72e6 to your computer and use it in GitHub Desktop.
Save rhuss/1015bf1ffa6bedcd72e6 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

@rhuss
Copy link
Author

rhuss commented Oct 7, 2015

For the docker-maven-plugin you can use mvn docker:build for creating your image and

mvn docker:push -Ddocker.registry=docker-registry.vagrant.f8:80 \
                            -Ddocker.username=$(oc whoami) \
                            -Ddocker.password=$(oc whoami -t)

considering that you are logged in as foo.

@rhuss
Copy link
Author

rhuss commented Oct 28, 2015

The most important things are:

  • You must login with a user having permissions on the project to which the image belongs (admin is fine)
  • An image belongs to the project with the username part of the image. E.g. Image fabric8/blubber:latest belongs to the project fabric8 (which must exist)
  • You must login with docker and don't forget the registry address as last argument to docker login

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