dockerfile创建服务lnmp和tomcat

系列文章目录

`

文章目录

  • 系列文章目录
  • 一、dockerfile创建服务
    • 1.dockerfile创建tomcat
    • 2.dockerfile创建lnmp
  • 总结

一、dockerfile创建服务

1.dockerfile创建tomcat

mkdir /opt/tomcat
cd /opt/tomcat/
#将apache-tomcat-9.0.16.tar.gz包和jdk-8u91-linux-x64.tar.gz包拷贝到tomcat目录下
tar xf apache-tomcat-9.0.16.tar.gz 
tar xf jdk-8u91-linux-x64.tar.gz 
vim Dockerfile
FROM centos:7
MAINTAINER this is tomcat image from centos7 
#安装jdk
ADD jdk-8u91-linux-x64.tar.gz /usr/local/
ENV JAVA_HOME=/usr/local/jdk1.8.0_91
ENV JRE_HOME=${JAVA_HOME}/jre
ENV CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:$PATH
#安装tomcat
ADD apache-tomcat-9.0.16.tar.gz /usr/local/
EXPOSE 8080
#前台运行tomcat
ENTRYPOINT ["/usr/local/apache-tomcat-9.0.16/bin/catalina.sh","run"]
docker pull centos:7
docker build -t tomcat:centos7 .

dockerfile创建服务lnmp和tomcat_第1张图片

docker run -itd --name c4 -p 8080:8080 tomcat:centos7

在这里插入图片描述

访问http://192.168.169.10:8080/

dockerfile创建服务lnmp和tomcat_第2张图片

2.dockerfile创建lnmp

#部署php(容器IP 为 172.18.0.30)
mkdir /opt/php
cd /opt/php

上传 php-7.1.10.tar.bz2 到 /opt/php 目录中

vim Dockerfile

FROM centos:7
MAINTAINER this is php image 
RUN yum -y install gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel gcc gcc-c++ make

ADD php-7.1.10.tar.bz2 /opt/
RUN cd /opt/php-7.1.10 && \
./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip && make -j2 && make install && \
cp /opt/php-7.1.10/php.ini-production /usr/local/php/lib/php.ini && \
sed -i '939c date.timezone = Asia/Shanghai' /usr/local/php/lib/php.ini && \
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf && \
sed -i '17c pid = run/php-fpm.pid' /usr/local/php/etc/php-fpm.conf && \
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf && \
useradd -M -s /sbin/nologin nginx && \
sed -i -e '23c user = nginx' -e '24c group = nginx' -e '36c listen = 172.18.0.30:9000' -e '62c listen.allowed_clients = 172.17.0.9' /usr/local/php/etc/php-fpm.d/www.conf
EXPOSE 9000
ENTRYPOINT ["/usr/local/php/sbin/php-fpm","-F"]

总结

你可能感兴趣的:(tomcat,linux,centos)