我正在尝试设置一个具有多个容器的web服务器--但首先要为我的反向代理设置一个简单的设置。
我的对接者-Compose.yml看起来如下:
version: '3'
services:
reverse-proxy:
container_name: reverse-proxy
hostname: reverse-proxy
image: nginx:latest
ports:
- 80:80
volumes:
- ./nginx-config/conf.d:/etc/nginx/conf.d
- ./html:/usr/share/nginx/html
environment:
- NGINX_PORT=80
- ENV=development具有nginx-config文件夹结构,如:
nginx-config
|- templates
|-default.conf.template
|- sites-available
|- mysite.conf.templatedefault.conf.template看起来是这样的:
server {
listen ${NGINX_PORT} default_server;
listen [::]:${NGINX_PORT} default_server;
server_name _;
root /usr/share/nginx/html;
charset UTF-8;
error_page 404 /notfound.html;
location = /notfound.html {
allow all;
}
location / {
return 404;
}
access_log off;
log_not_found off;
error_log /var/log/nginx/error.log error;
}但是,每当我运行docker-compose --context myremote up时,它就不能工作,抛出以下输出:
reverse-proxy | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
reverse-proxy | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
reverse-proxy | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
reverse-proxy | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
reverse-proxy | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs from the packaged version, exiting
reverse-proxy | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
reverse-proxy | /docker-entrypoint.sh: Configuration complete; ready for start up它都在nginx/config/config(至少在本地机器上)生成正确的输出。
有什么办法可以利用自定义配置和模板使用坞-撰写,而不会遇到这样的问题?
发布于 2020-06-05 16:34:37
问题解决了。
我试图在EC2机器上使用一个停靠器上下文来执行这个操作。
虽然Docker --context [context]已经成为稳定版本(至少对于MacOS)的一部分,但是docker-compose --context [context]是在v1.26.0-rc2上添加的,因此此时您需要安装Docker才能使其工作。
我使用的是set context [context],而不是显式的--context表单,这意味着我实际上是在本地部署,但并不知道。
https://stackoverflow.com/questions/62214607
复制相似问题