手动构建nginx
docker ps |awk ‘{print $1}‘|sed -n ‘2,$‘p |xargs docker stop ;
docker ps -a|awk ‘{print $1}‘|sed -n ‘2,$‘p|xargs docker rm ;
docker run -it --name ngx-img centos
yum -y install wget gcc gcc-c++ make openssl-devel ntp
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate cn.ntp.org.cn
wget http://nginx.org/download/nginx-1.12.0.tar.gz
wget --no-check-certificate https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz
wget http://cn2.php.net/distributions/php-7.0.2.tar.gz
useradd -s /sbin/nolog -M www
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.39
make && make install
/usr/local/nginx/sbin/nginx
vi /etc/rc.local /usr/local/nginx/sbin/nginx #这条没用
vi /usr/local/nginx/conf/nginx.conf daemon off;
docker run -d -p 90:80 lijie/my-ngx:20170415v3 /usr/local/nginx/sbin/nginx
然后可以通过网页访问nginx的页面。
编写Dockerfile
# This is My Dockerfile
# Version 1.0
# Author LiJie
#Base images
From centos
#MAINTAINER
MAINTAINER Alex Li
#ADD
ADD pcre-8.39.tar.gz /usr/local/src
ADD nginx-1.12.0.tar.gz /usr/local/src
ADD php-7.0.2.tar.gz /usr/local/src
#RUN
RUN yum -y install wget gcc gcc-c++ make openssl-devel ntp libxml2-devel libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxslt-devel
RUN useradd -s /sbin/noloing -M www
#WORKDIR
WORKDIR /usr/local/src/nginx-1.12.0
RUN ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.39 && make && make install
WORKDIR /usr/local/src/php-7.0.2
RUN ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pear --with-png-dir --with-zlib --with-zlib-dir --with-openssl-dir --with-jpeg-dir --enable-fpm --enable-libxml --enable-mbstring --enable-zip && make && make install
RUN mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
RUN mv /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
ENV PATH /usr/local/nginx/sbin:/usr/local/php/sbin:$PATH
EXPOSE 80 9000
CMD ["./start.sh"]
docker build -t nginx-file:v1 /opt/docker-file/nginx
docker run -d -p 9090:9000 -p 8080:8000 ngx-php:04161058
# This is My Dockerfile
# Version 1.0
# Author LiJie
#Base images
From centos
#MAINTAINER
MAINTAINER Alex Li
#ADD
ADD pcre-8.39.tar.gz /usr/local/src
ADD nginx-1.12.0.tar.gz /usr/local/src
#RUN
RUN yum -y install wget gcc gcc-c++ make openssl-devel ntp
RUN useradd -s /sbin/noloing -M www
#WORKDIR
WORKDIR /usr/local/src/nginx-1.12.0
RUN ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.39 && make && make install
WORKDIR /usr/local/src/php-7.1.4
RUN ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pear --with-png-dir --with-zlib --with-zlib-dir --with-openssl-dir --with-jpeg-dir --enable-fpm --enable-libxml --enable-mbstring --enable-zip
RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80
CMD ["nginx"]
yum -y install wget gcc gcc-c++ make openssl-devel ntp libxml2-devel libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxslt libxslt-devel
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /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
cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm