Lab 2 - BYO Container

Return to Workshop

Bring your own docker

It’s easy to get started with OpenShift whether you’re using our app templates or bringing your existing assets. In this quick lab we will deploy an application using an exisiting container image. OpenShift will create an image stream for the image as well as deploy and manage containers based on that image. And we will dig into the details to show how all that works.

Let’s point OpenShift to an existing built container image

Verify you're still in the project we created at the end of the last lab by going to the terminal and typing the following:
$ oc projects
You should see something *similar* in the last line of the output:
$ Using project "demo-0" on server "".
If you don't, use the following command to use the correct project:
$ oc project demo-0
In the terminal and type the following:
$ oc new-app sonatype/nexus:oss
The output should show something *similar* to below:
--> Found container image ae52f07 (4 months old) from Docker Hub for "sonatype/nexus:oss"

    Red Hat Universal Base Image 7
    The Universal Base Image is designed and engineered to be the base layer for all of your 
containerized applications, middleware and utilities. This base image is freely redistributable, 
but Red Hat only supports Red Hat technologies through subscriptions for Red Hat products. 
This image is maintained by Red Hat and updated regularly.

    Tags: base rhel7

    * An image stream tag will be created as "nexus:oss" that will track this image

--> Creating resources ... "nexus" created
    deployment.apps "nexus" created
    service "nexus" created
--> Success
    Application is not exposed. You can expose services to the outside world by executing one or 
more of the commands below:
     'oc expose svc/nexus'
    Run 'oc status' to view your app.  
Now, let's create a route, so that you can get to the app:
$ oc expose svc/nexus
Switch to "Developer" mode, by clicking on the menu, in the top left corner, where it says "Administrator", and pick "Developer"

Switch to "Project: demo-0", by clicking on the menu, in the top left, where it says "Project" and pick "demo-0"

Click "+Add"

Click "Container Image", to add an existing image from the container registry

Select the option for "Image name from external registry" and enter "sonatype/nexus:oss", then ensure that the image is validated.

Enter the values shown, in the image above.

Application Namenexus-app
ResourcesDeployment Config
Create a route to the applicationChecked

Click "Create"

We can browse our project details with the command line

Try typing the following to see what is available to ‘get’:

$ oc project demo-YOUR#

$ oc get all

Now let’s look at what our image stream has in it:

$ oc get is
$ oc describe is/nexus

An image stream can be used to automatically perform an action, such as updating a deployment, when a new image, in our case a new version of the nexus image, is created.

The app is running in a pod, let’s look at that:

$ oc describe pods

We can see those details using the web console too

Let’s look at the image stream.

Click on "Developer", in the top left corner, and change it to "Administrator"

Click on "Builds", in the left-side menu, and then "Image Streams"

This shows a list of all image streams within the project.

Now click on the "nexus" image stream

You should see something similar to this:

Test out the nexus webapp

Change the context menu (the menu, in the top left, that contains “Administrator” and “Developer” back to “Developer”, and click on the arrow, at the top right of the “nexus” thumbnail, to open the webapp’s route.

You will get a new browser window or tab, containing the following:

Good work - this error is expected; since the nexus console is on /nexus

Go to this URL:

… to get the Nexus console. Of course, we have not provided persistent storage; so, any and all work will be lost.

Let’s clean this up

Let’s clean up all this to get ready for the next lab:

$ oc delete all --selector app=nexus


In this lab you’ve deployed an example container image, pulled from, into a pod running in OpenShift. You exposed a route for clients to access that service via thier web browsers. And you learned how to get and describe resources using the command line and the web console. Hopefully, this basic lab also helped to get you familiar with using the CLI and navigating within the web console.

Workshop Details

Domain Red Hat Logo
Student ID

Return to Workshop