Search This Blog

Tuesday, January 8, 2019

How to run a jar file as an image in openshift.

Boot your docker host, it will be a boot to docker iso booted over virtual box.

Get the jar first, either make a runnable jar in eclipse or create one with jar -cfm commands.

Once jar is ready make a simple docker file but make sure you have right permissions of
the mounts else it will work fine in docker bu tnot in openshift.


sample docker file.
FROM java:8
WORKDIR /app
RUN chgrp -R 0 /app && \
    chmod -R g=u /app
ADD server.jar server.jar
EXPOSE 9877
CMD java -jar server.jar


now using winscp on 22 transfer this docker file jar to the docker host / username docker/tcuser (default)
Now run a build  from that directory

docker buid -t fixserver .

now try to run
docker run -i -t -p 9877:9877 fixserver


if it runs fine , push it to docker, just login and push but make
sure tag is as per standard docker.io/uname/image:latest

Now run minishift in c drive , i mean open cmd and run minishift --vm-drive virtualbox start
make nodosfilewarning flag also if using cygwin.

now open the console, minishift console enter.. usually 

Now add to project , deploy an image , take second opotion 
search for the image url in docker.io/uname/imagename

it will give warning for root, continue with the deployment ..
and expose it via route or as external service on the node port

e.g $ oc expose dc mariadb --type=LoadBalancer --name=mariadb-ingress

$ oc export svc mariadb-ingressit will open a port on the node some random port, and it will start routing to pod port

check the binding on oc get svc

do a telnet from laptop to to the minishift vm host ip on that random port

it should listen to your service on that port and will rout it to any of the pod.


Ref.

sudo docker exec -i -t b359ba5cb67f  /bin/bash   loginto a container


















No comments:

Post a Comment