Wednesday, 15 June 2016

Docker for sample applications

Sample docker file:

FROM ubuntu:14.04

USER root
RUN apt-get update && apt-get install -y \
    python3 \
    curl && \
    rm -rf /var/lib/apt/lists/*
RUN groupadd -r nonroot && \
    useradd -r -g nonroot -d /home/nonroot -s /sbin/nologin -c "Nonroot User" nonroot && \
    mkdir /home/nonroot && \
    chown -R nonroot:nonroot /home/nonroot

USER nonroot
WORKDIR /home/nonroot/
RUN curl -o index.html http://info.cern.ch/hypertext/WWW/TheProject.html

USER nonroot
EXPOSE 3000
WORKDIR /home/nonroot/
CMD ["python3", "-m", "http.server", "3000"]


sudo docker build -t=docker-example .
sudo docker run -p 3000:3000 -i -t docker-example
 http://localhost:3000/

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install nodejs
npm install http-server

----------------------------

# DOCKER-VERSION 1.2.0
FROM centos:centos6
#Install WGET
RUN yum install -y wget
#Install tar
RUN yum install -y tar
# Download JDK
RUN cd /opt;
RUN yum -y install java-1.7.0-openjdk-devel
#gunzip JDK
#RUN cd /opt;gunzip jdk-7u67-linux-x64.tar.gz
#RUN cd /opt;tar xvf jdk-7u67-linux-x64.tar
#RUN alternatives –install /usr/bin/java java /opt/jdk1.7.0_67/bin/java 2
# Download Apache Tomcat 7
RUN cd /tmp;wget http://redrockdigimark.com/apachemirror/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz
# untar and move to proper location
RUN cd /tmp;gunzip apache-tomcat-8.0.36.tar.gz
RUN cd /tmp;tar xvf apache-tomcat-8.0.36.tar
RUN cd /tmp;mv apache-tomcat-8.0.36 /opt/tomcat8
RUN chmod -R 755 /opt/tomcat8
ENV JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.101.x86_64/
EXPOSE 8080
CMD /opt/tomcat8/bin/catalina.sh run


to run the docker:
docker run -it --rm -p 8080:8080 tel/tom1
http://ipaddress:8080

---------------------------

No comments:

Post a Comment