How to build from Origin's integrated registry?

10/17/2016

I'm trying to learn Openshift/Origin/Kubernetes, so am stuck on one of many newbie hiccups.

If I build an image using this yml file:

apiVersion: v1
items:
- apiVersion: v1
  kind: ImageStream
  metadata:
    annotations:
      openshift.io/generated-by: OpenShiftNewApp
    creationTimestamp: null
    labels:
      app: myapp-dev
    name: myapp-dev
  spec: {}
  status:
    dockerImageRepository: ""
- apiVersion: v1
  kind: BuildConfig
  metadata:
    annotations:
      openshift.io/generated-by: OpenShiftNewApp
    creationTimestamp: null
    labels:
      app: myapp-dev
    name: myapp-dev
  spec:
    output:
      to:
        kind: ImageStreamTag
        name: myapp-dev:latest
    postCommit: {}
    resources: {}
    source:
      git:
        ref: master
        uri: git@git.host:myproject/myapp.git
      secrets: []
      sourceSecret:
        name: "deploykey"
      type: Git
    strategy:
      dockerStrategy:
        dockerfilePath: Dockerfile
      type: Docker
    triggers:
    - type: ConfigChange
    - imageChange: {}
      type: ImageChange
  status:
    lastVersion: 0
kind: List
metadata: {}

And I have other Dockerfiles that I want to use the output image from the previous build, how do I reference the integrated registry within the Dockerfile? Right now, I'm just watching the build log and using the IP and port listed in the logs in the Dockerfile's FROM directive.

So the build logs show:

Successfully built 40ff8724d4dd
I1017 17:32:24.330274 1 docker.go:93] Pushing image 123.123.123.123:5000/myproject/myapp-dev:latest ...

So I used this in the Dockerfile:

FROM 123.123.123.123:5000/myproject/myapp-dev:latest  

Any guidance you can provide will be awesome.

I would like to do something like:

FROM integrated.registry/myproject/myapp-dev:latest

Thank you for your time!

-- Zhao Li
kubernetes
openshift-origin

1 Answer

10/18/2016

The build config object lets you override the FROM. If you look at the build config created by oc new-build or new-app you'll see the field spec.strategy.dockerStrategy.from which can point to any docker image you want. To point to an image stream use "kind" as "ImageStreamTag", set "name" to "myapp-dev:latest"

If you're building outside of OpenShift and have given your registry a public DNS name you can simply set the FROM to registry/project/name:tag

-- Clayton
Source: StackOverflow