Container: Developing an Application - Working With Images

OpenShift's documentation on working with images is here.

OpenShift classifies application artifacts into image streams. Building your application from source will result in an image tag being added to the image stream. By default, OpenShift will deploy the 'latest' tag from an image stream, which will most often correspond to the latest version of your application. But you may wish to deploy an alternate version, something other than latest.

There are two ways to deploy a version other than latest. You can make an explicit, descriptive tag of an image and deploy that tag. Here is an example of that. Notice the second command. This essentially aliases a sha tag to a more descriptive tag of 'production'.:

$ oc describe is apache-cosign
Name: apache-cosign
Namespace: chris-sandbox
...
Tags: 1

latest
pushed image

* 172.30.183.221:5000/chris-sandbox/apache-cosign@sha256:cf49fa40b6790c3fa764bb03fed5bfe14e5958f19f98feca4e135c085e2a32ab
2 months ago
172.30.183.221:5000/chris-sandbox/apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330
6 months ago

 

$ oc tag apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330 apache-cosign:production
Tag apache-cosign:production set to apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330.

 

$ oc describe is apache-cosign
Name: apache-cosign
Namespace: chris-sandbox
...
Tags: 2

latest
pushed image

* 172.30.183.221:5000/chris-sandbox/apache-cosign@sha256:cf49fa40b6790c3fa764bb03fed5bfe14e5958f19f98feca4e135c085e2a32ab
2 months ago
172.30.183.221:5000/chris-sandbox/apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330
6 months ago

production
tagged from apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330

* 172.30.183.221:5000/chris-sandbox/apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330
9 seconds ago

Once the tag has been created, it will be visible within within the 'Deployment' screen, under 'Edit' >> 'Images'.

The second method is to grab the sha value of a specific tag from the image stream and add that to your deployment configuration. To do this, describe the image stream as in the example above, copy the sha value (the value after sha256: in the image stream) and paste into the yaml of your deployment configuration.To access the yaml of your deployment configuration, go to: 'Deployments' >> {your deployment name} >> "Edit YAML'. Paste the value under spec: containers: image: to look like this:

containers:
- name: apache-cosign
image: >-
172.30.183.221:5000/chris-sandbox/apache-cosign@sha256:cd9cce1d10d6468208207698ac59e4cf418b595646516e2b63c3ae17ab0bd330

Last Updated: 
Thursday, September 20, 2018