Thursday, August 27, 2015

Why dockerizing your application is essential?

Running our app on virtual box is a bit costly operation, as VMs are heavy and slow.This also requires effort in setting upend provisioning.

Whereas in case of Docker, It is lightweight, fast and very easy to configure/provision using a docker file where application specific instruction can be added.

Docker 

-Has a central repository of docker images, which developer can pull from different location.
-Can run many container running on a single machine.

commands:
Creating image :Create image : docker build -t <image_name>:1.0 .
Running app :    docker run -d -p 8080:8080 <image_name>:<v_1.0>
get automatic assigned ip :docker-machine ip default

#Setting env variable

ENV abc=hello

Dockerfile sample:

FROM <docker_repository>
#Install java8
FROM java:8
#Install java7 + maven
FROM jamesdbloom/docker-java7-maven

#Install only Maven
RUN apt-get update && \
    apt-get install -y maven

ADD your_app_root/trunk /opt/your_app
COPY your_app_root/settings.xml /usr/share/maven/conf/

#changing working directory
WORKDIR /opt/your_app/

#Exposing port to be available to the external machine.
EXPOSE 8080

#How to start the image
RUN ["mvn", "install"]
CMD ["mvn", "jetty:run"]

No comments:

Post a Comment