- download nginx image
wget https://nginx.org/download/nginx-1.19.2.tar.gz
extract nginx.conf and fastcgi_params from nginx-1.19.2.tar.gz
vi www.conf
server {
listen 80;
root /usr/local/nginx/html;
index index.htm index.html index.php;
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
- create Dockerfile
FROM centos7.8:v1
RUN useradd -M -s /sbin/nologin www
ADD nginx-1.19.2.tar.gz /usr/local/src
RUN yum install -y openssl openssl-devel libxslt-devel gd gd-devel GeoIP GeoIP-devel pcre pcre-devel libxm12 libxm12-dev
WORKDIR /usr/local/src/nginx-1.19.2
RUN ./configure --user=www --group=www --prefix=/usr/local/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module && make && make install
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
COPY fastcgi_params /usr/local/nginx/conf/fastcgi_params
RUN mkdir /usr/local/nginx/conf/conf.d
COPY www.conf /usr/local/nginx/conf/conf.d/www.conf
EXPOSE 80
CMD ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]
- Run docker build -t nginx1.19:v1 .