Search code examples
dockeropenshiftopenshift-origin

Running a docker image in Openshift Origin


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?


Solution

  • 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.