我使用了下面的docker-compose.yml在docker-enviroment上安装了一个nginx-proxy。
version: "2"
services:
nginx:
image: nginx
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/conf.d"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "../../../volumes/proxy/certs:/etc/nginx/certs:ro"
networks:
- proxy-tier
nginx-gen:
image: jwilder/docker-gen
container_name: nginx-gen
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "../../../volumes/proxy/templates/nginx-compose-v2.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -only-exposed -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes_from:
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "../../../volumes/proxy/certs:/etc/nginx/certs:rw"
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
networks:
proxy-tier:
external:
name: nginx-proxy
当我将它们添加到上面的compose文件中并按照以下语法为容器添加时,我能够安装诸如ghost和discourse之类的应用程序:
environment:
- VIRTUAL_HOST=site.example.com
- LETSENCRYPT_HOST=site.example.com
- LETSENCRYPT_EMAIL=email@example.com
networks:
- proxy-tier
因此,我的书架上有一个letencrypt-nginx-proxy,话语和鬼影。现在,当我想添加应用程序时,我不想每次都在compose.yml中进行编辑,因此我尝试将其拆分为多个堆栈。 我没有为letencrypt-nginx-proxy安装堆栈,也没有为其他应用程序安装堆栈。
我用于代理的语法是本文中的第一个compose文件。 为了进行测试,我尝试使用以下语法安装Nginx-webserver:
version: "2"
services:
nginx:
image: nginx
container_name: simple-site
volumes:
- "../../../volumes/examples/simple-site/conf.d/:/etc/nginx/conf.d"
environment:
- VIRTUAL_HOST=site.example.com
- LETSENCRYPT_HOST=site.example.com
- LETSENCRYPT_EMAIL=email@example.com
networks:
- proxy-tier
networks:
proxy-tier:
external:
name: nginx-proxy
我无法访问网络服务器。 是否有可能在自己的堆栈中创建nginx代理并将该代理也用于其他堆栈? 我必须如何编辑撰写文件才能成功?