Docker Phinx迁移getaddrinfo失败

时间:2019-06-30 17:52:53

标签: php docker

我是docker的新手,正在尝试将使用Phinx进行迁移的现有PHP代码库进行容器化。当我去运行docker-compose build时,它开始构建php服务并引发以下错误:

PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name does
   not resolve

我假设它与服务的顺序或mysql服务有关,特别是在实际构建过程中未运行/设置其他服务的主机名,因为如果在映像后进行了主机名查找,则主机名解析将正常工作已建立并运行。

这是我的docker-compose.yml内容:

version: '3.2'

services:

  nginx:
    build: './docker/nginx/'
    ports:
      - '8080:80'
    volumes:
      - ./:/var/www/html
    links:
      - mysql
      - mysql:app

  mysql:
    image: mysql:5.7
    volumes:
      - "mysql_data:/var/lib/mysql"
    environment:
      - MYSQL_ROOT_PASSWORD=rootpass
      - MYSQL_DATABASE=app
      - MYSQL_USER=app
      - MYSQL_PASSWORD=password
    ports:
      - '3306:3306'
    restart: unless-stopped

  redis:
    image: redis
    ports:
      - '6379:6379'
    restart: unless-stopped

  php:
    build:
      context: ./
      dockerfile: './docker/php/Dockerfile'
    volumes:
      - ./:/var/www/html/
    links:
      - mysql
      - mysql:app

volumes:
  mysql_data:

这是我的PHP Dockerfile:

FROM php:7.2.7-fpm-alpine3.7
RUN apk update; \
    apk upgrade;
RUN docker-php-ext-install pdo pdo_mysql
RUN curl -sS https://getcomposer.org/installer | \
    php -- --install-dir=/usr/bin/ --filename=composer
WORKDIR /var/www/html
COPY . /var/www/html
#RUN composer install --no-dev --no-interaction -o

RUN vendor/bin/phinx migrate 

0 个答案:

没有答案