Skip to content Skip to sidebar Skip to footer

How to Upload Docker Image to Openshirft

How to deploy Docker images on OpenShift?

Shardul Latkar

OpenShift is a container application platform which sits on top of Kubernetes and is a superset. Anything that works in Kubernetes will also run in OpenShift with an added advantage that it lets you easily and quickly build, develop, and deploy any of your infrastructures. It is a PaaS that abstracts the underlying components by providing an interface that runs on top of IaaS.

How to deploy applications using Docker on OpenShift cluster?

You can deploy applications within a few minutes using Docker images.
Hither we volition consider using an prototype from DockerHub which is a cloud-based registry service that allows you to link to code repositories, builds your images and tests them, stores manually pushed images, and links to Docker Cloud and then you can deploy images to your hosts.

Steps to deploy a nginx server on OpenShift cluster:

1) Login to your projection:
oc project <projectname>

[root@localhost ~]# oc new-project appdeployment
Now using projection "appdeployment" on server.

2) Create a new application:
oc new-app <applicationname>

[root@localhost ~]# oc new-app nginx:latest --> Establish Docker prototype e4e6d42 (iv days onetime) from Docker Hub for "nginx:latest" * An image stream will exist created as "nginx:latest" that will track this image * This image volition be deployed in deployment config "nginx" * Port lxxx/tcp will exist load balanced past service "nginx" * Other containers can admission this service through the hostname "nginx" * Alert: Image "nginx:latest" runs as the 'root' user which may not be permitted past your cluster ambassador  --> Creating resources ...     imagestream "nginx" created     deploymentconfig "nginx" created     service "nginx" created --> Success     Run 'oc status' to view your app.            

That'due south it! Your nginx application is deployed.

You can check status of your app past running command:
oc status <applicationname>

[root@localhost ~]# oc status nginx

OpenShift takes the stage and writes definition for a pod, service, deployment config, and replication controller and then spawns upwards a new container.

You can get pod information with control:

[root@localhost ~]# oc get pods
Proper noun READY STATUS RESTARTS AGE
nginx-ane-s4dbq 0/i CrashLoopBackOff 3 1m

Yous can see logs for your deployed nginx application:

[root@localhost ~]# oc logs -p nginx-ane-s4dbq
2017/07/15 19:18:09 [warn] one#1: the "user" directive makes sense just if the master procedure runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
nginx: [warn] the "user" directive makes sense merely if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
2017/07/15 nineteen:xviii:09 [emerg] 1#1: mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)
nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)

Boom! The mistake you see is because nginx image tried to run as root user and OpenShift prevented it from running as root. This can be fixed past either changing the Docker nginx paradigm or by telling OpenShift to allow this projection to be run as root. This tin can be configured in OpenShift by changing security context constraints equally follows:

[root@localhost ~]# oadm policy add together-scc-to-user anyuid -z default

After calculation security constraint, yous demand to re-deploy the application and y'all tin see our nginx is up and running.

[root@localhost ~]# oc deploy nginx

Yous can test your application by doing a curl:

              [root@localhost ~]# oc get endpoints NAME      ENDPOINTS        AGE nginx     10.129.0.74:80   41m  [root@localhost ~]# ringlet 10.129.0.74:80Welcome to nginx!   <style>     body {         width: 35em;         margin: 0 auto;         font-family: Tahoma, Verdana, Arial, sans-serif;     } </manner>  <h3>Welcome to nginx!</h3> If you see this page, the nginx web server is successfully installed and working. Farther configuration is required.  For online documentation and support delight refer to <a href="http://nginx.org/">nginx.org</a>. Commercial support is available at <a href="http://nginx.com/">nginx.com</a>. <em>Thank you for using nginx.</em>            

Yous tin create a route by providing a public hostname for that route which is configured with the DNS server to make the application publicly visible.

Conclusion:

OpenShift provides an like shooting fish in a barrel platform to bring Docker and Kubernetes to the enterprise which makes building, deploying, testing, and running applications faster and easier.

Topics: Deject, DevOps, & Containers, OpenShift, Containerization, Nginx, Kubernetes, Docker

corneliushicithore.blogspot.com

Source: https://www.opcito.com/blogs/how-to-deploy-docker-images-on-openshift

Post a Comment for "How to Upload Docker Image to Openshirft"