Docke构建nginx tomcat镜像
# 构建ngixn镜像
#设置基础镜像
FROM centos
#安装环境 下载软件包并解压
RUN yum install -y wget proc-devel net-tools gcc zlib zlib-devel make openssl-devel
RUN wget https://nginx.org/download/nginx-1.14.0.tar.gz
RUN tar xvf nginx-1.14.0.tar.gz
#进入目录 编译安装
WORKDIR nginx-1.14.0
RUN ./configure --prefix=/usr/local/nginx && make && make install
#开启80端口和443端口
EXPOSE 80
EXPOSE 443
#修改配置文件,以非deamon方式启动
RUN echo "daemon off;">>/usr/local/nginx/conf/nginx.conf
#复制服务脚本并设置权限
WORKDIR /root/nginx
ADD run.sh /run.sh
RUN chmod 755 /run.sh
#启动容器时执行脚本
CMD ["/run.sh"]
cat run.sh
#!/bin/bash
/usr/local/nginx/sbin/nginx
构建tomcat镜像
#设置基础镜像
FROM centos
#创建目录
RUN mkdir -p /usr/local
#安装jdk以及设置环境变量
ADD jdk1.8.0_211 /usr/local/java
ADD apache-tomcat-7.0.94 /usr/local/tomcat
ENV JAVA_HOME /usr/local/java
ENV JAVA_BIN /usr/local/java/bin
ENV JRE_HOME /usr/local/java/jre
ENV PATH $PATH:/usr/local/java/bin:/usr/local/java/jre/bin
ENV CLAS:SPATH /usr/local/java/jre/bin:/usr/local/java/lib:/usr/local/java/jre/lib/charsets.jar
#开启端口
EXPOSE 8080
#启动时运行tomcat
CMD ["/usr/local/apache-tomcat-7.0.94/bin/catalina.sh","run"]
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
爱吃可爱多!
喜欢就支持一下吧
打赏
微信
支付宝