9

I am very new to Openshift Origin. I am now trying out the possibility of deploying my docker containers in OpenShift origin. For that I created a very simple docker container that adds two numbers and produce the result:

https://github.com/abrahamjaison01/openshifttest

I created a docker image locally and a public docker image in docker hub:

docker pull abrahamjaison/openshifttest

I run the docker image locally as follows:

 [root@mymachine /]# docker run -it --rm abrahamjaison/openshifttest
 Enter first large number 
 12345 
 Enter second large number 
 54321 
 Result of addition = 66666

Since I am completely new to Openshift, I have no idea on how to deploy this in the Openshift environment.

I created a new project: oc new-project openshifttest

Then a new app: oc new-app docker.io/abrahamjaison/openshifttest

But then I do not know how I can access the console/terminal to provide the inputs. Also many a times when I run this I get the output as "deployment failed" when I issue the command "oc status".

Basically I would like to know how I can deploy this docker image on openshift and how I will be able to access the terminal to provide the inputs for performing the addition.
Could someone help me out with this?

2 Answers 2

3

OpenShift is principally for long running services such as web application and database. It isn't really intended for running a Docker container to wrap a command which then returns a result to the console and exits.

To get a better understand of how OpenShift 3 is used, download and read the free eBook at:

The closest you will get to do the same as docker run is the oc run command, but it sort of defeats the whole point of what OpenShift is for. You are better off using Docker on your own system for what you are describing.

A guess at the command you would use if really wanted to try would be:

oc run test -i --tty --rm --image=abrahamjaison/openshifttest

As I say though, not really intended for doing this. That oc run exists is more for testing when having deployment problems for your applications.

6
  • 1
    Thanks. It actually helped me to deploy my docker image. However, I still have a doubt over oc new-app and oc run. How are they different? My use case is that I have a docker image that requires some inputs during the startup and then based on those passed parameters, it will start a daemon process and sustain. Since I am completely new to openshift, I cannot differentiate between the use of oc new-app and oc run & services and pods. Also when I do oc new-app I am unable to get the terminal access to provide inputs. oc run -i -tty provides me an interface to provide the inputs. Commented Oct 27, 2016 at 5:17
  • If you want to provide inputs to an application with oc new-app you need to pass them in environment variables. You cannot pass them an interactive way from the command line by way of the application prompting for them, at the point the application is being started. Commented Oct 27, 2016 at 5:43
  • 1
    The oc new-app command is intended for services like web applications that will run all the time and which if they exit for some reason need to be restarted. It isn't intended for jobs which take some input and run to completion. Kubernetes has a concept of jobs for running something which is intended to exit which you can use in OpenShift, but your application would have to upload results somewhere, or store them in a persistent volume so can be retrieved. Commented Oct 27, 2016 at 5:45
  • Okay..! I think I'm getting there..! :) One more doubt that arise is when we issue oc new-app a service is being started, right. So when we issue oc run command what is exactly being started- service or dc or a pod? Commented Oct 27, 2016 at 6:22
  • When you use oc run, probably just a pod. Commented Oct 27, 2016 at 6:31
3

Following the "Creating an Application From an Image" part, the syntax should be:

oc new-app abrahamjaison/openshifttest

By default, OpenShift will look for the image in DockerHub.
But that supposes you have pushed your GitHub image there first: see "Store images on Docker Hub". That might be the missing step in your process.

The interaction with oc is done with the OpenShift CLI or web console, as illustrated in the authentication page.

2
  • Well thanks, but within openshift, how will I be able to access the terminal to provide the inputs? Like when running docker when can provide the tag "-it" in the docker run command to bring it to the terminal. But in this case, how will I be able to provide the inputs for the calculator function? Commented Oct 26, 2016 at 7:33
  • @AbrahamJaison by using either the OpenShift CLI or web console. See docs.openshift.org/latest/dev_guide/authentication.html
    – VonC
    Commented Oct 26, 2016 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.