harbor中nginx-photon升级nginx

1、进入容器查看当前编译安装插件

nginx -V

--prefix=/etc//nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log --add-module=../nginx-njs/njs-0.4.2/nginx --with-http_ssl_module \
--with-pcre --with-ipv6 --with-stream --with-http_auth_request_module --with-http_sub_module \
--with-http_stub_status_module --with-http_v2_module

 

2、下载njs模块

git地址:https://github.com/nginx/njs.git

yum -y install git

cd /usr/local/nginx-njs

git clone https://github.com/nginx/njs.git

 

 

3、在 本地编译安装nginx

#下载nginx源码包:
wget http://nginx.org/download/nginx-1.21.6.tar.gz
# 解压
tar zxf nginx-1.21.6.tar.gz -C /usr/local/
# 编译安装
./configure --prefix=/etc//nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --add-module=../nginx-njs/njs/nginx --with-http_ssl_module --with-pcre --with-ipv6 --with-stream --with-http_auth_request_module --with-http_sub_module --with-http_stub_status_module --with-http_v2_module
make && make install
# 查看安装是否成功

[root@localhost nginx-photon]# nginx -V
nginx version: nginx/1.21.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc//nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --add-module=../nginx-njs/njs/nginx --with-http_ssl_module --with-pcre --with-ipv6 --with-stream --with-http_auth_request_module --with-http_sub_module --with-http_stub_status_module --with-http_v2_module
[root@localhost nginx-photon]# which nginx
/usr/sbin/nginx

 

 

4、准备查找nginx1.21.6依赖库并移动到Dockerfile所在文件夹中

find / -name libssl.so.1.1 exec cp {} /root/nginx-photon/ \;
find / -name libssl.so.10 exec cp {} /root/nginx-photon/ \;

find / -name libcrypto.so.10 exec cp {} /root/nginx-photon/ \;
cp /usr/sbin/nginx  /root/nginx-photon/

 

5、编辑Dockerfile

基础镜像下载地址:(https://hub.docker.com/r/goharbor/nginx-photon)

FROM goharbor/nginx-photon:v1.10.0
USER root
COPY nginx /usr/sbin/nginx
COPY libssl.so.10 /usr/lib64/libssl.so.10
COPY libcrypto.so.10 /usr/lib64/libcrypto.so.10
RUN chmod a+x /usr/sbin/nginx
RUN chown nginx:nginx /usr/sbin/nginx
USER nginx

 6、打包生成镜像

docker build -t nginx-photon:zk01 .
docker save nginx-photon:zk01 > nginx-photon.tar

 

7、上传至harbor服务器所在机器后载入镜像

docker load -i nginx-photon:zk01

 

8、修改docker-compose配置文件中nginx-photon镜像版本并重启镜像

docker-compose up

 

posted @ 2022-04-02 14:55  zk01  阅读(1130)  评论(0编辑  收藏  举报