介绍
大家好!有像您这样乐于助人且技能娴熟的成员真是太好了。在复制各种博客的分步说明以从小型托管 VPS 创建一整套 Docker 驱动的应用程序后,我陷入了困境。主要是用ghost、nginx和ssl创建博客。
问题
在执行 docker-compose.yml 时,nginx 容器会停止:
- nginx-gen | 2018/04/09 07:52:03 从 5 个容器生成“/etc/nginx/conf.d/default.conf”
- nginx-gen | 2018/04/09 07:52:03 发送容器“nginx”信号“1”
- nginx-gen | 2018/04/09 07:52:03 观看码头活动
- nginx | nginx-gen | 2018/04/09 07:52:03 /etc/nginx/conf.d/default.conf 的内容没有改变。跳过通知''
- nginx-gen | 2018/04/09 07:52:03 收到容器 789c0544cf96 的事件死亡
- nginx-gen | 2018/04/09 07:52:03 Debounce minTimer 被解雇
- nginx 以代码 2 退出
设置
- GCP CE g1-small(1 个 vCPU,1.7 GB 内存)
- Ubuntu 16.04.4 LTS
- Docker 版本 18.03.0-ce,构建 0520e24
- docker-compose 版本 1.20.1,构建 5d8c71b
泊坞窗图像
- jwilder/nginx-代理
- jwilder/docker-gen
- jrcs/letsencrypt-nginx-proxy-companion
文件#
- nginx.tmpl(来源:https ://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl )
- 码头工人-compose.yml
笔记
- 所有文件都在同一个文件夹中。
- 已经使用docker network create nginx-proxy
码头工人-compose.yml
version: '2'
services:
nginx:
image: jwilder/nginx-proxy
container_name: nginx
ports:
- '80:80'
- '443:443'
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /etc/nginx/conf.d
- /etc/nginx/vhost.d # to update vhost configuration
- /usr/share/nginx/html # to write challenge files
- "../../../volumes/proxy/certs:/etc/nginx/certs:ro"
networks:
- default
nginx-gen:
image: jwilder/docker-gen
container_name: nginx-gen
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "./:/etc/docker-gen/templates/:ro"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait -5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
ssl-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: ssl-companion
volumes_from:
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "../../../volumes/proxy/certs:/etc/nginx/certs:rw"
mariadb:
image: 'bitnami/mariadb:latest'
volumes:
- '/mariadb_data:/bitnami:z'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=<USER_NAME> # change <USER_NAME>
- MARIADB_DATABASE=<DB_NAME> # change <DB_NAME>
blog:
image: 'bitnami/ghost:latest'
expose:
- '2368'
depends_on:
- mariadb
environment:
- VIRTUAL_HOST=<YOUR_VR_HOST> # change <YOUR_VR_HOST>
- LETSENCRYPT_HOST=<YOUR_LC_HOST> # change <YOUR_LC_HOST>
- LETSENCRYPT_EMAIL=<YOUR_EMAIL> # change <YOUR_EMAIL>
- GHOST_DATABASE_USER=<USER_NAME> # change <USER_NAME>
- GHOST_DATABASE_NAME=<DB_NAME> # change <DB_NAME>
- GHOST_HOST=localhost
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- '/ghost_data:/bitnami:z'
restart: unless-stopped
networks:
- default
networks:
default:
external:
name: nginx-proxy