Docker LNMP之Dockerfile

1,使用centos:7制作自己的centos7:v1镜像。

FROM centos:7
LABEL maintainer="www" description="my centos"
RUN rm -rf /etc/yum.repos.d/* && \
    curl -o /etc/yum.repos.d/My-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo &>/dev/null && \
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/My-Base.repo && \
    yum makecache && \
    yum clean all && \
    rm -rf /var/log/yum.log && \
    rm -rf /var/cache/yum/*

该镜像仅做yum 源的修改。

 

2,使用centos7:v1镜像制作nginx镜像。

FROM centos7:v1
LABEL maintainer="www" description="PRJF NGINX"
RUN useradd  -s /sbin/nologin nginx && \
    yum -y install gcc pcre-devel gd-devel openssl-devel wget make && \
    mkdir -p /soft/server/nginx && \
    cd /soft/server/ && \
    wget http://nginx.org/download/nginx-1.16.1.tar.gz && \
    tar -zxvf nginx-1.16.1.tar.gz && \
    cd nginx-1.16.1 && \
    ./configure --prefix=/soft/server/nginx --user=nginx --group=nginx --error-log-path=/soft/server/nginx/logs/error.log --http-log-path=/soft/server/nginx/logs/access.log --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_stub_status_module --with-http_sub_module && \
    make && make install && \
    rm -rf /soft/server/nginx-1.16.1* && \
    yum clean all
VOLUME /soft/server/nginx/conf /soft/server/nginx/logs /soft/server/nginx/html
WORKDIR /soft/server/nginx/
EXPOSE 80
ENTRYPOINT ["sbin/nginx", "-g", "daemon off;"] 

3,使用centos7:v1镜像制作phpfpm镜像。

FROM centos7:v1
LABEL maintainer="www" description="PRJF PHP"
RUN yum install -y wget gcc gcc-c++ make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers && \
    mkdir -p /soft/server/php && cd /soft/ && \
    wget https://www.php.net/distributions/php-7.2.24.tar.gz && \
    tar -zxvf php-7.2.24.tar.gz && \
    cd php-7.2.24 && \
    ./configure --prefix=/soft/server/php --with-config-file-path=/soft/server/php/etc --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pear  --disable-phar --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl && \
    make && make install && \
    cp php.ini-production /soft/server/php/etc/php.ini && \
	cd /soft/server/php/etc && mv php-fpm.conf.default php-fpm.conf && mv php-fpm.d/www.conf.default php-fpm.d/www.conf && \
	cd /soft && rm -rf php-7* && \
    yum clean all && \
    rm -rf /var/log/yum.log && \
    rm -rf /var/cache/yum/* 
WORKDIR /soft/server/php
EXPOSE 9000
VOLUME /soft/server/php/etc /soft/server/php/log /soft/server/nginx/html
CMD ["/soft/server/php/sbin/php-fpm", "-F"]

 

你可能感兴趣的:(Docker,Docker,lnmp)