目录结构, 如图
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
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。