Deploy a Docker Image on Openshift Platform
This article aims to investigate how to deploy a docker image on an openshift platform and run in there. Before deployment process, first let’s examine what is openshift and why this platform is being used.
What is Openshift
Openshift is a cloud development platform. This works on platform as a service (PaaS). It created by RedHat. This platform is free and open-source cloud-based platform. It allows developers to create, test and run their applications and deploy them into the cloud.
Openshift supports various languages such as python, Java, Perl, PHP, etc.. This platform helps portability. That means, customers can migrate deployments to other cloud vendor environments.
Openshift platform can be run on AWS or cloud. Openshift provides a developer based platform with using docker and kubernetes containers.
Docker Image Deployment on Openshift Platform
Openshift can be used two different ways. Using that platform on windows terminal is the first option. Second one uses web console platform. In this article second option will be used.
In a web browser, write www.openshift.com. After that, there is a sign in button on the right top of openshift web page. Click that and this leads another page. In this page, there are some register questions. Thereafter filling registration page, there is an third page to open web console page. Click there open web console button. Finally the page is viewed.
Click Create Project button and fill in the opening blanks.
After creating a project, open that project. Click deploy image button in the page.
In opening window, click image name radio button. Write there docker.io/dockerhub_username/repository_name then click the search button at the end of the same line. This action will start to search your username and repository name in dockerhub. When it finds that, this is seen as follows.
Click deploy button.
Click Close button and refresh page. The page will show itself as follows.
To access the project from outside, a route has to be given. Route creates a corridor for the project. This corridor helps that the project becomes accessible from outsiders.
Click Create Route button.
Click Create button and then the link of that route is ready.
Now the route is ready which means the project can be accessed by others. Run that link from another client’s pc and the project can be seen as follows.
How to Deploy an Image from Terminal
Above, web console was used. This time how to deploy a docker image using windows terminal will be shown.
First download openshift for windows at https://www.openshift.org/download.html . After that, open windows terminal and find the oc.exe file. Run this file.
Now oc connection is ready. write terminal oc login. The system asks the username and password. Write same username and password when create an account in openshift.
To create a project write oc new-project <project_name>.
To create a new application in the project, write oc new-app dockerhub_name/reporsitory_name .
To create a route, write oc expose service <service_name> .
After all these commands, open web console and there is the project,application and the route.
When click the route, this will forward to the app.