拉取centos镜像
[root@localhost ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 2 months ago 231MB
构建nginx镜像
[root@localhost ~]# docker run --name nginx -it centos
[root@3c7370935253 /]# useradd -r -M -s /sbin/nologin nginx
[root@3c7370935253 /]# yum -y install pcre-devel pcre gcc gcc-c++ openssl-devel zlib zlib-devel make vim wget openssl openssl-devel gd-devel
[root@3c7370935253 /]# mkdir -p /var/log/nginx
[root@3c7370935253 /]# chown -R nginx.nginx /var/log/nginx
[root@3c7370935253 /]# cd /usr/src/
[root@3c7370935253 src]# wget https://nginx.org/download/nginx-1.20.1.tar.gz
[root@3c7370935253 src]# tar xf nginx-1.20.1.tar.gz
[root@3c7370935253 src]# cd nginx-1.20.1
[root@3c7370935253 nginx-1.20.1]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@3c7370935253 nginx-1.20.1]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
[root@3c7370935253 nginx-1.20.1]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@3c7370935253 nginx-1.20.1]# source /etc/p