猿问

docker-compose.yml中php-fpm服务启动exit with code 0?

docker-compose.yml

version: '2.1'
services:
  nginx:
    image: 'nginx'
    ports:
      - "80:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./src:/var/www/app
    depends_on:
      - php
  php:
    image: 'php:7.1-fpm'
    ports:
      - "9000:9000"
    volumes:
      - ./src:/var/www/app
      - ./php/php-fpm.conf:/usr/local/etc/php-fpm.conf

php-fpm.conf

[global]
pid = /var/run/php-fpm.pid
error_log = /var/log/php-fpm.log
log_level = notice


[www]
listen = 127.0.0.1:9000
listen.backlog = -1
;   listen.allowed_clients = 127.0.0.1
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
user = www-data
group = www-data
pm = dynamic
pm.max_children = 60
pm.start_servers = 30
pm.min_spare_servers = 30
pm.max_spare_servers = 60
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log

Problem

PS D:\SalamanderDocker> docker-compose up
Starting salamanderdocker_php_1 ...
Starting salamanderdocker_php_1 ... done
Starting salamanderdocker_nginx_1 ...
Starting salamanderdocker_nginx_1 ... done
Attaching to salamanderdocker_php_1, salamanderdocker_nginx_1
salamanderdocker_php_1 exited with code 0
nginx_1  | 2017/10/18 04:36:48 [emerg] 1#1: host not found in upstream "php" in /etc/nginx/nginx.conf:42
nginx_1  | nginx: [emerg] host not found in upstream "php" in /etc/nginx/nginx.conf:42
salamanderdocker_nginx_1 exited with code 1

知道docker是需要一个进程挂在那边的,那这里是什么原因呢?

慕仙森
浏览 2420回答 2
2回答

郎朗坤

因为nginx进程报错了,所以导致进程退出了。 把你的nginx的配置文件贴一下看看。
随时随地看视频慕课网APP
我要回答