構建目錄結構
nginx-docker
--default.conf
--docker-compose.yml
--web
---note
拉取文檔倉庫并編譯
git pull && rm -rf _book && gitbook install && gitbook build .
編寫nginx服務配置
? nginx-docker cat default.conf
server {
listen 80;
server_name your_hostname;
root /web;
location /note {
alias /web/note/_book;
index index.html;
}
location ^~ gitbook/ {
root /web/gitbook/;
}
}
通過docker啟動
編寫docker-compse.yml
? nginx-docker cat docker-compose.yml
version: '2'
services:
nginx:
image: nginx:latest
restart: always
container_name: nginx-web
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./web:/web
- ./default.conf:/etc/nginx/conf.d/default.conf
啟動容器
? docker-compose up -d