目录构造, 如图
docker-compose.yml 配置文件
version: '3.1'
services:
nginx:
image: daocloud.io/library/nginx:1.14
container_name: nginx
restart: always
privileged: true
environment:
- TZ=Asia/Shanghai
ports:
- 999:80
- 998:443
volumes:
- /etc/localtime:/etc/localtime:ro
- ./conf:/etc/nginx/conf.d
- ./logs:/var/log/nginx
- ./html:/opt/dist:ro
networks:
- nginx_bridge
networks:
nginx_bridge:
driver: bridge
conf/nginx.conf 配置文件
server {
listen 80;
server_name thatsmycicd;
gzip on;
gzip_buffers 32 4k;
gzip_comp_level 6;
gzip_min_length 200;
gzip_types text/css text/xml application/x-javascript;
location / {
root /opt/dist;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {root /opt/dist;}
}
这个 startup.sh 是过后为了删除多余容器写的, 留着备用
#! /usr/bin/bash
# 定义一个名称变量
network_name="nginx_bridge"
filterName=`docker network ls | grep $network_name | awk '{print $2}'`
if ["$filterName" == ""]; then
# 不存在就创立
docker network create $network_name
echo "Created network $network_name success!!"
fi
docker-compose -f ./docker-compose.yml up -d
docker ps -a
docker logs -f nginx