Red Hat OpenShift WorldTour
  • Red Hat OpenShift Workshop
  • Accessing IBM Cloud - the Free Lite Account
  • Lab 1 - Start with a Docker Image
  • Command Line Interface - Using the CLI in a Terminal
  • Claiming Your Red Hat OpenShift Cluster for This Workshop
  • Pre-Requesites Lab 2
  • Lab 2 - Using an existing image to create a project
  • Lab 3 - stretch goal
  • Lab 3 with LogDNA
  • Next Steps
    • IBM/minishift101 - step 1 - accessing cluster
    • IBM/minishift101 - step 2 - creating an app from source
    • IBM/minishift101 - step 3
    • IBM/minishift101 - step 4 networking
  • How Did You Like This Workshop?
  • FAQ
    • Lab 2 v 3.x - Using an existing image to create a project
    • Lab 3 - Deploying a Project to Red Hat OpenShift Kubernetes Cluster
      • Lab 3 - setting up
      • Lab 3 - instructions on creating an OpenShift project
Powered by GitBook
On this page
  • 1. Creating an app
  • 1.1 Creating an app from source
  • 1.2 Creating an app from a DockerHub image
  • 1.3 Creating an app from an OpenShift template
  • 1.4 Creating an app from the OpenShift UI

Was this helpful?

  1. Next Steps

IBM/minishift101 - step 2 - creating an app from source

After creating a project as instructed in the previous lab (Step 1), the next step is to create an OpenShift application in the cluster.

1. Creating an app

There are several ways in which you can create an app in OpenShift:

  • From source code

  • From DockerHub images

  • From OpenShift templates

  • From the OpenShift UI

1.1 Creating an app from source

With oc new-app command, you can create an application in OpenShift from some existing source code either locally or with the url to the repository. If a source repository is specified, new-app will check to see which build strategy to use (Docker or Source).

With the former, a runnable image is created, whereas as the latter, new-app will try to identify the language by looking at the files in the project's root directory and then use an appropriate builder.

To build from a local Dockerfile:

$ oc new-app /path/to/local/or/remote/Dockerfile

To build from source:

$ oc new-app path/to/local/or/remote/repository.git

1.2 Creating an app from a DockerHub image

Similar to Docker, OpenShift is also configured to the public image registry DockerHub. If you specify an image that exists in DockerHub, the new-app command will create a runnable image directly from this image.

For example, if you wanted to create an app from the official nginx image, you would run:

$ oc new-app nginx

You are not limited to the DockerHub registry, however - as with Docker, you are able to specify images that are stored in private registries too:

$ oc new-app myregistry:8000/example/image

1.3 Creating an app from an OpenShift template

OpenShift templates are basically starter applications that have been configured ready for OpenShift. These cover frequently used applications deployed in containers e.g. Ruby, Node and MongoDB.

nodejs-ex
├── openshift
│   └── templates
│       ├── nodejs.json
│       ├── nodejs-mongodb.json
│       └── nodejs-mongodb-persistent.json
├── package.json
├── README.md
├── server.js
├── tests
│   └── app_test.js
└── views
    └── index.html

To deploy it, you can run:

$ oc new-app -f /path/to/nodejs.json

1.4 Creating an app from the OpenShift UI

$ minishift start
...

The server is accessible via web console at:
    https://192.168.64.11:8443/console

You are logged in as:
    User:     developer
    Password: <any value>

Login to the UI:

As mentioned in the minishift start output, you can use the user developer and password as any string of characters (at least one) and you will be able to access the UI.

Access the catalog:

PreviousIBM/minishift101 - step 1 - accessing clusterNextIBM/minishift101 - step 3

Last updated 5 years ago

Was this helpful?

The looks as follows:

As this template lives in a repo, we could have also run this from source as described in

If you're not a fan of the cli and wanted a more visual way of deploying applications in your cluster, you also have the option of using the OpenShift console. This is available locally at the address given after running minishift start as we did in the :

Once you login, you will be redirected to the browser catalog where there will be a number of sample applications available for you to chose to deploy. This mirrors the OpenShift template steps we saw in . We can also create and switch between projects but note, you are limited to the provided sample applications available in the console catalog.

See this for a more comprehensive overview of how to use the new-app command to create OpenShift applications.

Congratulations! You have learnt several ways to create applications in OpenShift! To see how we can manage our applications in OpenShift, let's continue on to the

nodejs template
section 1.1
setup
section 1.2
reference
next Lab (Lab 3)