FROM ubuntu MAINTAINER Rafael lzj# 更新源,安装ssh server RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe"> /etc/apt/sources.list RUN apt-get update RUN apt-get install -y openssh-server RUN apt-get install unzip RUN mkdir -p /var/run/sshd # 设置root ssh远程登录密码为123456 RUN echo "root:123456" | chpasswd # setup tomcat RUN mkdir /opt/bag COPY tomcat /opt/bag/ RUN perl -p -i -e "s/8080/5880/g" /opt/bag/conf/server.xml # install example app on wildfy COPY bag.war /opt/bag/webapps/bag/ RUN unzip /opt/bag/webapps/bag/bag.war -d /opt/bag/webapps/bag/ # setup maven RUN mkdir /opt/maven COPY apache-maven-3.2.2-bin.zip /opt/maven/ RUN unzip /opt/maven/apache-maven-3.2.2-bin.zip -d /opt/maven/ # setup Java RUN mkdir /opt/java COPY jdk-7u75-linux-x64.gz /opt/java/ # change dir to Java installation dir WORKDIR /opt/java/ #RUN apt-get install -y maven RUN tar -zxf jdk-7u75-linux-x64.gz # setup nvironment variables RUN update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.7.0_75/bin/javac 100 RUN update-alternatives --install /usr/bin/java java /opt/java/jdk1.7.0_75/bin/java 100 RUN update-alternatives --display java RUN java -version # Expose the ports we're interested in EXPOSE 8080 5880 # Set the default command to run on boot # This will boot WildFly in the standalone mode and bind to all interface #CMD /opt/bag/bin/startup.sh && tail -f /opt/bag/logs/catalina.out CMD /opt/bag/bin/startup.sh && /usr/sbin/sshd -D # 设置Tomcat7初始化运行,SSH终端服务器作为后台运行 #ENTRYPOINT service tomcat7 start
然后创建镜像,为了提交到私有仓库所以如此命名:
docker build -t 192.168.1.104:5000/bag .
然后运行:
docker run -d -p 8001:8001 -v /home/luzijun/Bag/bag:/opt/Bag/webapps/bag 192.168.1.104:5000/bag
通过把宿主机上的项目目录挂载到容器里面的tomcat内的webapps目录下,就能做到实时更新了,不过如果是更新的.class文件则需要重启tomcat
下面这幅图是我找到的,个人感觉非常好,大家学习后可以把这幅图的流程都走通就差不多啦,至于对这幅图的理解这里我就不说了
好了,这就是我的一些收货,希望对大家有所帮助,纯原创,duang~~