Dockerfile模板-安装Nginx


# 基础镜像版本 必须步骤
FROM ubuntu
# 作者信息
MAINTAINER king

# 将需要的安装包和文件添加到容器(可以的话,配置文件提前修改好! 必须步骤
ADD ElecManageSystem /mnt/ElecManageSystem
ADD Tools /mnt

# 安装wget
#RUN apt-get -y -q install wget
# 添加apt-get源
#RUN wget -q http://download.opensuse.org/repositories/home:tpokorra:mono/xUbuntu_12.04/Release.key -O- | apt-key add -
# 卸载wget
#RUN apt-get remove -y --auto-remove wget
# 添加openSUSE的镜像源列表
#RUN sh -c "echo 'deb http://download.opensuse.org/repositories/home:/tpokorra:/mono/xUbuntu_12.04/ /' >> /etc/apt/sources.list.d/mono-opt.list"
# 安装mono,安装前需要升级apt-get 必须步骤
RUN apt-get update
#RUN apt-get -q install mono-opt#


#安装make 必须步骤
RUN apt-get -y install make
#安装gcc和gcc-c++ 必须步骤
RUN apt-get -y install gcc
RUN apt-get -y install g++

# 安装vim 必须步骤
# RUN apt-get -y install vim
# 安装的内容较多,包含gcc
# RUN apt-get -y install build-essential
# 安装yum
# RUN apt-get -y install yum

# 安装pcre必须步骤。进入/esr/mnt/
#RUN cd /usr/mnt/
# 下载
#RUN wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
# 解压文件
#RUN tar -zxvf pcre-8.38.tar.gz
# 进入解压后的文件夹
#RUN cd pcre-8.38
# 生成makefile
#RUN ./configure
# 编译
#RUN make
# 安装
#RUN make install
# 避免error: the HTTP rewrite module requires the PCRE library 必须步骤
RUN apt-get install libpcre3 libpcre3-dev


# 安装zlib库 必须步骤
#RUN cd /usr/mnt/
#RUN wget http://zlib.net/zlib-1.2.8.tar.gz
#RUN tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
#RUN ./configure
#RUN make
#RUN make install

# 安装openssl
#RUN cd /opt
#RUN wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
#RUN tar -zxvf openssl-1.0.1c.tar.gz
#RUN ./config
#RUN make
#RUN rm /usr/bin/pod2man
#RUN make install

# 安装Nginx 必须步骤
#Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:
#RUN cd /usr/local/
#RUN wget http://nginx.org/download/nginx-1.2.8.tar.gz
#RUN tar -zxvf nginx-1.2.8.tar.gz
#RUN cd nginx-1.2.8  
#RUN ./configure --prefix=/usr/local/nginx 
#RUN make
#RUN make install


# 安装完Nginx后,如果是32位系统
# RUN ln -s /usr/local/lib/libpcre.so.1 /lib
# 如果是64位系统
# RUN ln -s /usr/local/lib/libpcre.so.1 /lib64


# 映射端口并启动容器,开启nginx 必须步骤
docker run -i -p 1314:80 -t DockerImage
/usr/local/nginx/sbin/nginx
# 如需重启Nginx
/usr/local/nginx/sbin/nginx -s reload



# Nginx.conf文件模板如下:

FROM ubuntu
MAINTAINER king

ADD Tools /opt

RUN apt-get -y update
RUN apt-get -y install make
RUN apt-get -y install gcc
RUN apt-get -y install g++
RUN apt-get -y install libpcre3 libpcre3-dev

进入容器后安装vim、pcre、zlib、openssl、nginx

然后移动web应用文件夹到/usr/local/nginx/html下,把web应用文件夹下的其他文件夹都移动到app下。

配置nginx.conf,其中 root html/ElecManageSystem/app 放到server下,而不是location下。

启动nginx,/usr/local/nginx/sbin/nginx

重启nginx,/usr/local/nginx/sbin/nginx -s reload

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM