docker php-fpm:端口9000之间的服务之间连接失败

时间:2019-06-25 09:11:41

标签: php symfony docker docker-compose

我正在设置一个配置以运行我的环境。我有一个mysql,redis,nginx和php-fpm。

mysql和redis服务都可以,但是当我启动nginx和php时,我的环境无法运行。

对fastcgi_pass的nginx配置调用:php:9000

错误是:

[error] 6#6: *1 connect() failed (113: No route to host) while connecting to upstream, client: 192.168.224.1, server: ~.*, request: "POST /sellers HTTP/1.1", upstream: "fastcgi://192.168.224.4:9000", host: "127.0.0.1:8080"

我的Dockerfile是:

FROM php:7.2-fpm-alpine

WORKDIR /app

# Install composer
RUN apk --update add curl && rm /var/cache/apk/*
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

RUN docker-php-ext-install pdo pdo_mysql

# Copy files
COPY . /app/

## THE LIFE SAVER
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

RUN composer up
CMD /wait && bin/console doctrine:migrations:migrate

我的docker-compose是:

version: '3'

services:
  mysql:
    image: mysql:5.7
    restart: unless-stopped
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: database
      MYSQL_DATABASE: cart

  redis:
    image: redis:alpine
    ports:
      - '6379:6379'

  web:
    image: nginx:latest
    depends_on:
      - php
    ports:
      - '8080:80'
    volumes:
      - .:/app
      - ./docker/site.conf:/etc/nginx/conf.d/site.conf

  php:
    build:
      context: .
    depends_on:
      - mysql
    volumes:
      - .:/app
    environment:
      - APP_ENV=prod
      - APP_SECRET=aaaa
      - DATABASE_URL=mysql://root:database@mysql:3306/cart
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - WAIT_HOSTS= mysql:3306

0 个答案:

没有答案