docker镜像制作 centos6 nginx1.15.6 with NGINX_UPSYNC_MODULE
首先我选择了在centos6里部署nginx的镜像,如果大家选择的是centos7,自己重新修改吧
这里的问题点有几个:
1,make的版本选择,因为我下载了最新的cmake,需要c++11编译
这玩意的安装比较麻烦,在前面一篇随笔里已经写过gcc在centos里的安装
2,docker容器的层级,我使用了 以下办法来减少层级,不在同一个层级,有些操作会出现问题哦
RUN ..... \
&& .....
3,CMD和Endpoint的使用,我这里只用了endpoint,但nginx作为后台运行,需要额外添加参数
ENTRYPOINT ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]
4,调试,在调试过程中最好使用“docker run -itd nginx_centos6”,把-itd改为-it,这样能够查看到出错信息
5,真正部署时,我使用了dockercompose文件,可以让很多参数进行额外的配置
# Version 0.1 FROM centos:6 MAINTAINER kuba si812cn@163.com
ENV NGINX_UPSYNC_MODULE_VERSION 2.1.0
ENV CMAKE_VERSION 3.12.4
ENV ZLIB_VERSION 1.2.11
ENV PCRE_VERSION 8.42
ENV OPENSSL_VERSION 1_1_1
ENV NGINX_HTTP_CONCAT_VERSION 1.2.2
ENV GEOIP_VERSION 1.4.8
ENV NGINX_VERSION 1.15.6 RUN mkdir -p /opt/software
WORKDIR /opt/software/
RUN yum -y update;yum -y install epel-release wget tar xz unzip make autoconf automake curl curl-devel gcc gcc-c++ gcc-g77 kernel-devel gd gd-devel mlocate \
&& yum -y install centos-release-scl-rh centos-release-scl \
&& yum -y install devtoolset-6-gcc.x86_64 devtoolset-6-gcc-c++.x86_64 \
&& yum -y install libtool \
&& scl enable devtoolset-6 bash \
&& updatedb \
&& yum clean all \
&& source /opt/rh/devtoolset-6/enable \
&& export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc \
&& export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++ \
&& wget https://github.com/weibocom/nginx-upsync-module/archive/v${NGINX_UPSYNC_MODULE_VERSION}.zip \
&& unzip v${NGINX_UPSYNC_MODULE_VERSION}.zip \
&& rm -f v${NGINX_UPSYNC_MODULE_VERSION}.zip \
&& wget https://github.com/Kitware/CMake/archive/v${CMAKE_VERSION}.zip \
&& unzip v${CMAKE_VERSION}.zip \
&& rm -f v${CMAKE_VERSION}.zip \
&& cd CMake-${CMAKE_VERSION}/ \
&& ./bootstrap \
&& gmake \
&& make install \
&& cd ../ \
&& wget https://github.com/madler/zlib/archive/v${ZLIB_VERSION}.zip \
&& unzip v${ZLIB_VERSION}.zip \
&& rm -f v${ZLIB_VERSION}.zip \
&& cd zlib-${ZLIB_VERSION}/ \
&& ./configure \
&& make \
&& make install \
&& cd ../ \
&& wget https://ftp.pcre.org/pub/pcre/pcre-${PCRE_VERSION}.zip \
&& unzip pcre-${PCRE_VERSION}.zip \
&& rm -f pcre-${PCRE_VERSION}.zip \
&& cd pcre-${PCRE_VERSION}/ \
&& ./configure --prefix=/usr/local/pcre \
&& make \
&& make install \
&& cd ../ \
&& wget https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.zip \
&& unzip OpenSSL_${OPENSSL_VERSION}.zip \
&& rm -f OpenSSL_${OPENSSL_VERSION}.zip \
&& cd openssl-OpenSSL_${OPENSSL_VERSION}/ \
&& ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl --shared \
&& make \
&& make install \
&& cd /usr/local/ \
&& ln -sf openssl ssl \
&& echo "/usr/local/openssl/lib" >>/etc/ld.so.conf \
&& ldconfig \
&& echo "export OPENSSL=/usr/local/openssl/bin">>/etc/profile \
&& echo "export PATH=\$OPENSSL:\$PATH">>/etc/profile \
&& source /etc/profile \
&& ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl \
&& ln -sf /usr/local/openssl/include/openssl /usr/include/openssl \
&& ln -sf /usr/local/openssl/lib/libcrypto.so.1.1 /lib/libcrypto.so.6 \
&& ldconfig -v \
&& cd /opt/software/ \
&& wget https://github.com/alibaba/nginx-http-concat/archive/${NGINX_HTTP_CONCAT_VERSION}.zip \
&& unzip ${NGINX_HTTP_CONCAT_VERSION}.zip \
&& rm -f ${NGINX_HTTP_CONCAT_VERSION}.zip \
&& wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz \
&& tar zxvf GeoIP.tar.gz \
&& rm -f GeoIP.tar.gz \
&& cd GeoIP-${GEOIP_VERSION}/ \
&& ./configure \
&& make \
&& make install \
&& updatedb \
&& locate libGeoIP.so.1 \
&& echo "/usr/local/lib" >> /etc/ld.so.conf \
&& ldconfig \
&& cd ../ \
&& wget https://github.com/nginx/nginx/archive/release-${NGINX_VERSION}.zip \
&& unzip release-${NGINX_VERSION}.zip \
&& rm -f release-${NGINX_VERSION}.zip \
&& groupadd www \
&& useradd -g www www -s /bin/false \
&& cd nginx-release-${NGINX_VERSION}/ \
&& ./auto/configure --prefix=/usr/local/nginx --user=www --group=www --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --without-http_memcached_module --with-http_ssl_module --with-openssl=/opt/software/openssl-OpenSSL_${OPENSSL_VERSION}/ --with-http_realip_module --with-http_image_filter_module --with-http_mp4_module --with-http_flv_module --with-pcre=/opt/software/pcre-${PCRE_VERSION}/ --with-zlib=/opt/software/zlib-${ZLIB_VERSION}/ --with-http_addition_module --with-http_geoip_module --with-http_sub_module --with-http_degradation_module --add-module=/opt/software/nginx-upsync-module-${NGINX_UPSYNC_MODULE_VERSION}/ --add-module=/opt/software/nginx-http-concat-${NGINX_HTTP_CONCAT_VERSION}/ \
&& make \
&& make install ADD ./nginx.conf /usr/local/nginx/conf/
ADD ./html/ /usr/local/nginx/html/ ENTRYPOINT ["/usr/local/nginx/sbin/nginx","-g","daemon off;"] EXPOSE 80 443
nginx.conf
user www www;
worker_processes 4; error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; pid logs/nginx.pid; events {
worker_connections 8096;
multi_accept on;
use epoll;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; client_max_body_size 10M;
sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; gzip on; server {
listen 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; error_page 404 /errors/404.html;
error_page 500 502 503 504 /errors/50x.html; location ^~ /errors/ {
root html;
} location / {
root html;
index index.html index.htm;
}
} }
创建镜像
docker build -t nginx_centos6 ./
启动镜像
docker run -it nginx_centos6
这样启动后,正常来说使用http://127.0.0.1是访问拒绝的,因为Docker里有自己的IP,需要隐射一下
我选择使用了docker_compose来配置隐射
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
# version: '2' services:
nginx0:
image: nginx_centos6
restart: always
container_name: nginx0
ports:
- 80:80
执行docker-compose -f docker-compose-nginx.yaml up -d 2>&1
一切OK
docker镜像制作 centos6 nginx1.15.6 with NGINX_UPSYNC_MODULE的更多相关文章
- MySQL、MongoDB、Redis数据库Docker镜像制作
		
MySQL.MongoDB.Redis数据库Docker镜像制作 在多台主机上进行数据库部署时,如果使用传统的MySQL的交互式的安装方式将会重复很多遍.如果做成镜像,那么我们只需要make once ...
 - 自动化kolla-ansible部署ubuntu20.04+openstack-victoria之镜像制作centos6.5-14
		
自动化kolla-ansible部署ubuntu20.04+openstack-victoria之镜像制作centos6.5-14 欢迎加QQ群:1026880196 进行交流学习 制作OpenSta ...
 - docker研究-4 docker镜像制作
		
这次实验以centos镜像为基础镜像进行相关docker镜像制作. 1. 下载centos镜像 [root@localhost ~]# docker pull centosUsing default ...
 - 《Docekr入门学习篇》——Docker镜像制作
		
Docker镜像制作 Docker镜像的构建分为两种,一种是手动构建,一种是dockerfile(自动构建) 手动构建 基于centos镜像进行构建制作Nginx镜像 [root@rbtnode1 ~ ...
 - Docker 镜像制作教程:针对不同语言的精简策略
		
本系列文章将分为三个部分: 第一部分着重介绍多阶段构建(multi-stage builds),因为这是镜像精简之路至关重要的一环.在这部分内容中,我会解释静态链接和动态链接的区别,它们对镜像带来的影 ...
 - Nginx+PHP7.3.9 Docker镜像制作
		
最近因项目需要制作了多个版本的php docker镜像,制作过程可谓是一波三折,因基于yum的方式安装php的方式在安装扩展插件时很不方便,不容易找到插件对应的yum源,所以PHP在docker镜像中 ...
 - doris 0.9.0版本docker镜像制作与使用
		
1. 安装docker 详情请参见本人博客 2. 编译doris 详情请参见doris官网文档 3. 在编译好的doris output文件夹下编写两个Dockerfile 3.1 Dockerfi ...
 - presto-gateway 试用以及docker 镜像制作
		
presto-gateway 是 lyft 团队开源 的prestodb 的工具.以下是一个简单的试用,以及碰到问题的解决 还有就是docker 镜像的制作 Dockerfile 很简单,本地构建然后 ...
 - 实战【docker 镜像制作与使用】
		
一.制作docker 镜像 使用spring boot 构建一个简单的web 项目,返回 “Hello,World ”字符串,使用 Maven 打成 jar 包,使用的Linux 环境是 Centos ...
 
随机推荐
- 雷林鹏分享:jQuery EasyUI 数据网格 - 条件设置行背景颜色
			
jQuery EasyUI 数据网格 - 条件设置行背景颜色 本教程将向您展示如何根据一些条件改变数据网格(datagrid)组件的行样式.当 listprice 值大于 50 时,我们将为该行设置不 ...
 - 3、VNC
			
VNC(Virtual Network Computing,虚拟网络计算机) VNC分为两部分组成:VNC server 和 VNC viewer VNC安装 1.yum install tigerv ...
 - 『Numpy』内存分析_利用共享内存创建数组
			
引.内存探究常用函数 id(),查询对象标识,通常返回的是对象的地址 sys.getsizeof(),返回的是 这个对象所占用的空间大小,对于数组来说,除了数组中每个值占用空间外,数组对象还会存储数组 ...
 - DBMS_NETWORK_ACL_ADMIN (OCP 053 第七题)
			
You create an access control list(ACL)using the DBMS_NETWORK_ACL_ADMIN package It is a list of users ...
 - 在Visual Studio 2017中安装bower
			
在项目目录下添加一个文件.bowerrc { "directory": "wwwroot/lib" } JS包默认安装到webroot的lib文件夹,可以通过. ...
 - vue中父组件给子组件传值,子组件给父组件传值
			
1.父组件传给子组件 父元素中 子元素中(通过props传值) 2.子组件传给父组件 子元素中(this.$emit(传过去的名字,传的参数)) 父元素中 通过changeShow的参数data 把修 ...
 - Python人工智能之路 - 第二篇 : 算法实在太难了有现成的直接用吧
			
本节内容 预备资料: 1.FFmpeg: 链接:https://pan.baidu.com/s/1jonSAa_TG2XuaJEy3iTmHg 密码:w6hk 2.baidu-aip: pip ins ...
 - java 线程操作
			
停止线程 创建“停止标记”,thread.interrupt() 准确的说interrupt()方法只是“告知线程该停止了”,而线程检查到该“告知”后,再通过其他的办法停止线程. 线程调用了inter ...
 - mvvm框架
			
了解mvvm框架吗 vue.js react.js angular.js 谈谈你对mvvm的认识 mvc View :用来把数据以某种方式呈现给用户 Model :其实就是数据 Controller ...
 - mysql 判断某字段是否包含中文
			
SELECT col FROM table WHERE LENGTH(col) != CHAR_LENGTH(col) LENGTH() 函数:返回字符串的长度,已字节符为单位 CHAR_LENGTH ...