2

It is easy to work with Openshift as a Container As A Service, see the detailed steps. So, via the docker client I can work with Openshift.

I would like to work on my laptop with Minishift. That's the local version of Openshift on your laptop.

Which docker registry should I use in combination with Minishift? Minishift doesn't have it's own registry - I guess.

So, I would like to do:

$ maven clean install -- building the application
$ oc login to your minishift environment
$ docker build -t myproject/mynewapplication:latest
$ docker tag -- ?? normally to a openshift docker registry entry
$ docker push -- ?? to a local docker registry?
$ on 1st time: $ oc new-app mynewapplication
$ on updates: $ oc rollout latest dc/mynewapplication-n myproject
tm1701
  • 7,307
  • 17
  • 79
  • 168

2 Answers2

7

I use just docker and oc cluster up which is very similar. The internal registry that is deployed has an address in the 172.30.0.0/16 space (ie. the default service network).

$ oc login -u system:admin
$ oc get svc -n default  | grep registry
docker-registry   ClusterIP   172.30.1.1     <none>        5000/TCP                  14m

Now, this service IP is internal to the cluster, but it can be exposed on the router:

$oc expose svc docker-registry -n default
$oc get route -n default  | grep registry
docker-registry   docker-registry-default.127.0.0.1.nip.io             docker-registry   5000-tcp                 None

In my example, the route was docker-registry-default.127.0.0.1.nip.io

With this route, you can log in with your developer account and your token

$oc login -u developer
$docker login docker-registry-default.127.0.0.1.nip.io -p $(oc whoami -t) -u developer
Login Succeeded

Note: oc cluster up is ephemeral by default; the docs can provide instructions on how to make this setup persistent.

One additional note is that if you want OpenShift to try to use some of it's native builders, you can simply run oc new-app . --name <appname> from within the your source code directory.

$ cat Dockerfile 
FROM centos:latest

$ oc new-app . --name=app1
--> Found Docker image 49f7960 (5 days old) from Docker Hub for "centos:latest"

    * An image stream will be created as "centos:latest" that will track the source image
    * A Docker build using binary input will be created
      * The resulting image will be pushed to image stream "app1:latest"
      * A binary build was created, use 'start-build --from-dir' to trigger a new build
    * This image will be deployed in deployment config "app1"
    * The image does not expose any ports - if you want to load balance or send traffic to this component
      you will need to create a service with 'expose dc/app1 --port=[port]' later
    * WARNING: Image "centos:latest" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources ...
    imagestream "centos" created
    imagestream "app1" created
    buildconfig "app1" created
    deploymentconfig "app1" created
--> Success
    Build scheduled, use 'oc logs -f bc/app1' to track its progress.
    Run 'oc status' to view your app.
stewartshea
  • 308
  • 1
  • 5
  • Didn't work for me. When running the `docker login` command I get an error: **Error response from daemon: Get https://docker-registry-default.192.168.64.2.nip.io/v2/: x509: certificate is valid for *.router.default.svc.cluster.local, router.default.svc.cluster.local, not docker-registry-default.192.168.64.2.nip.io** – Ronin Jun 03 '20 at 07:27
  • the solution was to instead use this command: `docker login -u developer -p $(oc whoami -t) $(minishift openshift registry)` see: https://docs.okd.io/3.11/minishift/openshift/openshift-docker-registry.html – Ronin Jun 03 '20 at 07:37
1

There is an internal image registry. You login to it and push images just like you suggest. You just need to know the address and what credentials you need. For details see:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • Your answer is, as I understand from the lined article, about the internal registry of Openshift. What I am looking for is the local registry when I use Minishift. Is there a registry known within the Minishift environment? I guess it will be thrown away after each fresh start? – tm1701 Jun 10 '18 at 17:38
  • 2
    Minishift is OpenShift. For your purposes it appears the same and you use the same procedure to access the internal registry. If you want to be picky about the implementation details, Minishift runs in a VM. In that VM there is a local docker daemon instance. Then ``oc cluster up`` runs in the VM. It will use that local docker instance in the VM as the registry. It is not thrown away on restart as it is part of the VM. It does not use local docker daemon instance on your own host. – Graham Dumpleton Jun 10 '18 at 21:59
  • Either way, for Minishift, a shortcut to get the details you need to work with the image registry is to run ``minishift docker-env`` and do what it tells you to do. – Graham Dumpleton Jun 10 '18 at 22:05