Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 493
Abraham Jaison Avatar asked Oct 26 '16 07:10

Abraham Jaison


2 Answers

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:

  • https://www.openshift.com/promotions/for-developers.html

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.

like image 108
Graham Dumpleton Avatar answered Sep 21 '22 01:09

Graham Dumpleton


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.

like image 23
VonC Avatar answered Sep 21 '22 01:09

VonC