This commit is contained in:
yangyu 2018-06-24 20:59:48 +08:00
parent bd5518572f
commit 6103075e92
4 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1 @@
# 常用docker

27
nginx/1.15.0/Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM centos:7
MAINTAINER Yang <yangyu@baiwang.com>
ENV NGINX_VERSION=1.15.0
RUN yum install -y wget make gcc pcre-devel gzip zlib zlib-devel
RUN cd / && wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz \
&& tar -zxvf nginx-$NGINX_VERSION.tar.gz \
&& rm -rf nginx-$NGINX_VERSION.tar.gz \
&& cd nginx-$NGINX_VERSION \
&& ./configure --prefix=/usr/local/nginx \
&& make \
&& make install \
&& cd .. \
&& rm -rf nginx-$NGINX_VERSION
RUN mkdir -p /nginx/conf && mkdir /nginx/logs/ && mkdir /nginx/www
EXPOSE 80
COPY start.sh /
RUN chmod 777 /start.sh
ENTRYPOINT ["/start.sh"]

8
nginx/1.15.0/start.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [ ! -e /nginx/conf/nginx.conf ]; then
cp /usr/local/nginx/conf/nginx.conf /nginx/conf
sed -i "s/mime.types/\/usr\/local\/nginx\/conf\/mime.types/" /nginx/conf/nginx.conf
fi
/usr/local/nginx/sbin/nginx -c /nginx/conf/nginx.conf -g 'daemon off;'

17
nginx/README.md Normal file
View File

@ -0,0 +1,17 @@
# nginx 搭建
## 创建镜像
进入相应的nginx版本执行以下命令
```bash
docker build -t nginx:1.15.0 .
```
## 启动容器
```bash
docker run -d --name nginx-1.15.0 \
--privileged=true \
--restart always \
-p 80:80 \
-v $PWD/conf:/nginx/conf \
-v $PWD/logs:/nginx/logs \
-v $PWD/www:/nginx/www \
nginx:1.15.0
```