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
然后创建镜像,为了提交到私有仓库所以如此命名:
1
docker build -t 192.168.1.104:5000/bag .
然后运行:
1
docker run -d -p 8001:8001 -v /home/luzijun/Bag/bag:/opt/Bag/webapps/bag 192.168.1.104:5000/bag