- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我最近开始迁移到 Docker 1.9 和 Docker-Compose 1.5 的网络功能以替换使用链接。
到目前为止,通过 docker-compose 连接到位于一组不同服务器中的我的 php5-fpm fastcgi 服务器的 nginx 没有任何问题。新虽然当我运行 docker-compose --x-networking up
我的 php-fpm、mongo 和 nginx 容器启动时,但是 nginx 立即退出 [emerg] 1#1: host在/etc/nginx/conf.d/default.conf:16 的上游“waapi_php_1”中找不到
但是,如果我在 php 和 mongo 容器正在运行(nginx 退出)时再次运行 docker-compose 命令,则 nginx 将从那时起启动并正常工作。
这是我的 docker-compose.yml
文件:
nginx:
image: nginx
ports:
- "42080:80"
volumes:
- ./config/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
php:
build: config/docker/php
ports:
- "42022:22"
volumes:
- .:/var/www/html
env_file: config/docker/php/.env.development
mongo:
image: mongo
ports:
- "42017:27017"
volumes:
- /var/mongodata/wa-api:/data/db
command: --smallfiles
这是我用于 nginx 的 default.conf
:
server {
listen 80;
root /var/www/test;
error_log /dev/stdout debug;
access_log /dev/stdout;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/.+\.php(/|$) {
# Referencing the php service host (Docker)
fastcgi_pass waapi_php_1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# We must reference the document_root of the external server ourselves here.
fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
如何让 nginx 只使用一个 docker-compose 调用?
最佳答案
这可以通过提到的 depends_on
指令解决,因为它现在已经实现(2016 年):
version: '2'
services:
nginx:
image: nginx
ports:
- "42080:80"
volumes:
- ./config/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- php
php:
build: config/docker/php
ports:
- "42022:22"
volumes:
- .:/var/www/html
env_file: config/docker/php/.env.development
depends_on:
- mongo
mongo:
image: mongo
ports:
- "42017:27017"
volumes:
- /var/mongodata/wa-api:/data/db
command: --smallfiles
成功测试:
$ docker-compose version
docker-compose version 1.8.0, build f3628c7
在 documentation 中查找更多详细信息.
还有一篇非常有趣的文章专门讨论这个话题:Controlling startup order in Compose
关于nginx - Docker 网络 - nginx : [emerg] host not found in upstream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33639138/
I'm getting this error after running sudo nginx command我在运行sudo nginx命令后收到此错误 nginx: [emerg] bin
我在我的一个子域上生成了 SSL 证书。然后我尝试 delete/revoke证书使用命令certbot delete .弹出一个小终端菜单,询问我要删除什么证书。我删除了我想删除的那个。现在,当运行
我正在设置新服务器。我选择的 Web 服务器是 NGINX。我想添加域名(例如 example.com)作为虚拟主机。我已经有另外两个域,它工作正常,但是当我尝试添加上述域并启动服务器时,它给了我:
我正在尝试通过集群中的Nginx容器将请求反向代理到共享相同覆盖网络的独立容器。 tldr;我收到以下错误: 2018/03/15 19:00:35 [emerg] 1#1: invalid host
我已经重新配置了 nginx,但无法使用以下配置重新启动它: server { listen 80; server_name www.example.com; return 3
我第一次尝试在 EC2 上使用 Rubber 进行设置(complete_passenger_nginx_postgresql)。我更改了配置文件中的一系列设置,使其适用于不同的 AMI(Ubuntu
我正在为 RHEL 7 中的反向代理配置 nginx,这是我的配置。 server { listen 8080; server_name localhost.com; location
我正在尝试在 Digital Ocean 的 Droplet 上的 Ubuntu 上配置 Nginx 服务器。 当我运行 sudo nginx -t 时,出现错误 [emerg] unknown "r
当我尝试重新启动Nginx并在控制台中写入此命令时 nginx -t 我有一个错误: nginx: [emerg] a duplicate default server for 0.0.0.0:80
如何创建 HTML 链接到紧急号码,如 911或 112 ? RFC says The phone number can be represented in either global or loca
在X-WAF部署中,您需要创建新的nginx配置文件。但是在测试nginx配置时,发现错误,nginx无法启动。 我指的是http://blog.51cto.com/14071176/2318054
我正在尝试在 nginx 中重写 url,下面是我的示例代码: server { listen 80; server_name example.com; root /ful
这是我的第一个问题!在这个网站上:Is there a kdevelop version that i can install on windows?在其中一个答案中,需要“运行 emerge qt、
由于/etc/fstab 中有错误的代码行,我无法启动我的 Linux 机器。目前我的机器将尝试启动并无限循环消息“欢迎使用紧急模式!...”。我无法进入控制台或登录。 在启动屏幕上点击退出并进入救援
我正在构建一个 Rails 应用程序,我正在设置应用程序以在 docker 上部署,并使用 Nginx 作为网络服务器。但是,我在为应用程序设置 Nginx 和 Docker 时遇到问题。 我在运行
当我点击其中一个建议时,下拉列表只消失,但听不到鼠标点击事件, 鼠标焦点和键盘事件等其他事件完美运行。 在我的输入代码结构中,组件通常位于另一个组件内,如下面的部分代码所示: 父组件 class Si
最近为了制作一个Docker镜像,在本地电脑上通过虚拟机安装了CentOS,顺便通过宝塔面板安装了阿里系的WEB环境。安装好以后Nginx始终无法启动,报错:nginx: [emerg] inval
几周来,我一直在使用 Android 模拟器、命令行和 Intellij,运行 ApiDemos 和我自己的应用程序,没有任何问题。 现在,没有任何异常或消息表明模拟器将只运行紧急调用应用程序的原因,
我开发了一个应用程序来跟踪用户位置(后台模式)并获得政府警察服务的用户许可。 根据苹果人机界面指南: 4.3 Apps that use location-based APIs for emergen
我在 mac OSX Snow Leopard 上安装了 Git,我尝试编辑我的 merge 和差异工具以使用 kdiff3 而不是 emerge。 但是当我尝试使用它时,它不会启动 kdiff 的
我是一名优秀的程序员,十分优秀!