$ oc new-app .
You can create a new OpenShift application using the
web console or
by running the
oc new-app command from the CLI. OpenShift
creates a new application by specifying source
code, images, or
new-app command looks for images
on the local Docker installation (if available), in a
registry, or an OpenShift
If you specify source code,
new-app attempts to construct a
build configuration that builds your
source into a new application
It also constructs a
configuration that deploys that new image, and a
provide load balanced access to the deployment that is running your image.
You can create a new application using the
oc new-app command from
new-app command allows you to create applications using source code from a
local or remote Git repository. If only a source repository is specified,
new-app tries to automatically determine the
strategy to use (
Source), and in the case of
builds, an appropriate language builder image.
You can tell
new-app to use a subdirectory of your source code repository by
--context-dir flag. Also, when specifying a remote URL, you can
specify a Git reference to use by appending
#[reference] to the end of the
If using a local Git repository, the repository must have an origin remote that points to a URL accessible by the OpenShift cluster.
$ oc new-app .
$ oc new-app https://github.com/openshift/sti-ruby.git \ --context-dir=2.0/test/puma-test-app
$ oc new-app https://github.com/openshift/ruby-hello-world.git#beta4
new-app finds a Dockerfile in the repository, it generates a
build strategy. Otherwise, it generates a
strategy. To use a specific strategy, set the
--strategy flag to either
new-appto Use the
DockerStrategy for a Local Source Repository:
$ oc new-app /home/user/code/myapp --strategy=docker
If creating a
new-app attempts to determine which language
builder to use based on the presence of certain files in the root of the
Rakefile, Gemfile, config.ru
After a language is detected,
new-app searches the OpenShift server for
stream tags that have a
supports annotation matching the detected language,
or an image stream that matches the name of the detected language. If a match is
new-app searches the Docker Hub
registry for an image that matches the detected language based on name.
To override the image that
new-app uses as the builder for a particular source
repository, the image (either an image stream or Docker specification) can be
specified along with the repository using a
~ as a separator.
$ oc new-app myproject/my-ruby~https://github.com/openshift/ruby-hello-world.git
$ oc new-app openshift/ruby-20-centos7:latest~/home/user/code/my-ruby-app
new-app command generates the necessary artifacts to deploy an existing
image as an application. Images can come from image streams in the OpenShift
server, images in a specific registry or Docker
Hub, or images in the local Docker server.
new-app command attempts to determine the type of image specified in the
arguments passed to it. However, you can explicitly tell
new-app whether the
image is a Docker image (using the
--docker-image argument) or an image stream
If you specify an image from your local Docker repository, you must ensure that the same image is available to the OpenShift cluster nodes.
$ oc new-app mysql
To create an application using an image in a private registry, specify the full Docker image specification.
$ oc new-app myregistry:5000/example/myimage
If the registry that the image comes from is not
with SSL, cluster administrators must ensure that the Docker daemon on the
OpenShift nodes is run with the
To create an application from an existing image stream, specify the namespace (optional), name, and tag (optional) for the image stream.
$ oc new-app my-stream:v1
new-app command can instantiate a template from a
previously stored template or from a template file. To instantiate a
previously stored template, specify the name of the template as an argument. For
example, store a
application template and use it to create an application.
$ oc create -f examples/sample-app/application-template-stibuild.json $ oc new-app ruby-helloworld-sample
To use a template in the file system directly, without first storing it in
OpenShift, use the
-f|--file argument or simply specify the file name as the
$ oc new-app -f examples/sample-app/application-template-stibuild.json
When creating an application based on a template, use the
-p|--param argument to set parameter values defined by the template.
$ oc new-app ruby-helloworld-sample \ -p ADMIN_USERNAME=admin,ADMIN_PASSWORD=mypassword
$ oc new-app openshift/postgresql-92-centos7 \ -e POSTGRESQL_USER=user \ -e POSTGRESQL_DATABASE=db \ -e POSTGRESQL_PASSWORD=password
When generating applications from source,
images, or templates,
you can use the
l|--label argument to add labels to objects created by
new-app. This is recommended, as labels make it easy to collectively select,
manipulate, and delete objects associated with the application.
$ oc new-app https://github.com/openshift/ruby-hello-world -l name=hello-world
new-app command generates OpenShift objects that will build, deploy, and
run the application being created. Normally, these objects are created in the
current project using names derived from the input source repositories or the
input images. However,
new-app allows you to modify this behavior.
To see a dry-run of what
new-app will create, you can use the
flag with a value of either
json. You can then use the output to
preview the objects that will be created, or redirect it to a file that you
can edit and then use with
oc create to create the OpenShift objects.
new-appArtifacts to a File, Edit Them, Then Create Them Using
$ oc new-app https://github.com/openshift/ruby-hello-world -o json > myapp.json $ vi myapp.json $ oc create -f myapp.json
Objects created by
new-app are normally named after the source repository or
the image used to generate them. You can set the name of the objects produced by
--name flag to the command.
new-appArtifacts with a Different Name:
$ oc new-app https://github.com/openshift/ruby-hello-world --name=myapp
new-app creates objects in the current project. However, you can tell
it to create objects in a different project that you have access to using the
new-appArtifacts in a Different Project:
$ oc new-app https://github.com/openshift/ruby-hello-world -n myproject
The set of artifacts created by
new-app depends on the artifacts passed as
input: source repositories, images, or templates.
Other objects can be generated when instantiating templates.
new-app command allows creating multiple applications from
source, images, or
templates at once. To do this, simply specify
multiple parameters to the
new-app call. Labels specified in the command line
apply to all objects created by the single call. Environment variables apply to
all components created from source or images.
$ oc new-app https://github.com/openshift/ruby-hello-world mysql
If a source code repository and a builder image are specified as separate
new-app command allows deploying multiple images together in a single pod.
In order to specify which images to group together, use the
+ separator. The
--group command line argument can also be used to specify which images should
be grouped together. To group the image built from a source repository with
other images, specify its builder image in the group.
$ oc new-app nginx+mysql
$ oc new-app \ ruby~https://github.com/openshift/ruby-hello-world \ mysql \ --group=ruby+mysql
You can also create applications using the web console:
While in the desired project, click Add to Project:
Enter the repository URL for the application to build:
Select either a builder image from the list of images in your project, or from the global library:
Only image stream tags which have the builder tag listed in their annotations will appear in this list, as demonstrated here:
kind: "ImageStream" apiVersion: "v1" metadata: name: "ruby" creationTimestamp: null spec: dockerImageRepository: "registry.access.redhat.com/openshift3/ruby-20-rhel7" tags: - name: "2.0" annotations: description: "Build and run Ruby 2.0 applications" iconClass: "icon-ruby" tags: "builder,ruby" (1) supports: "ruby:2.0,ruby" version: "2.0"
|1||Including builder here ensures this
Modify the settings in the new application screen to configure the objects to support your application:
|1||The builder image name and description.|
|2||The application name used for the generated OpenShift objects.|
|3||Routing configuration section for making this application publicly accessible.|
|4||Deployment configuration section for customizing deployment triggers and image environment variables.|
|5||Build configuration section for customizing build triggers.|
|6||Replica scaling section for configuring the number of running instances of the application.|
|7||The labels to assign to all items generated for the application. You can add and edit labels for all objects here.|