Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Docker Compose和NGINX的ECS上无法启动简单PHP应用程序_Docker_Nginx_Amazon Ecs - Fatal编程技术网

使用Docker Compose和NGINX的ECS上无法启动简单PHP应用程序

使用Docker Compose和NGINX的ECS上无法启动简单PHP应用程序,docker,nginx,amazon-ecs,Docker,Nginx,Amazon Ecs,我有一个非常简单的PHP应用程序,使用NGINX和Busybox构建Docker Compose。它在本地运行良好,但我无法让它在AWS ECS上的容器中正常启动。应用程序结构如下所示: Root --conf nginx.conf php.ini supervisord.conf --logs --sites default.vhost --www --default index.php aws-compose.yml docker-compose.yml Dock

我有一个非常简单的PHP应用程序,使用NGINX和Busybox构建Docker Compose。它在本地运行良好,但我无法让它在AWS ECS上的容器中正常启动。应用程序结构如下所示:

Root
--conf
  nginx.conf
  php.ini
  supervisord.conf
--logs
--sites
  default.vhost
--www
  --default
    index.php
aws-compose.yml
docker-compose.yml
Dockerfile
  - ./sites:/etc/nginx/conf.d
  - ./conf/nginx.conf:/etc/nginx/nginx.conf
重要文件包括:

aws-compose.yml

version: '2'
 services:

  web:
    image: nginx:alpine
    cpu_shares: 100
    mem_limit: 262144000
    restart: always
    ports:
      - "80:80"
      - "443:443"
    links:
      - php
    volumes:
      - /sites:/etc/nginx/conf.d
      - /conf/nginx.conf:/etc/nginx/nginx.conf
    volumes_from:
      - code

  php:
    image: '195367337191.dkr.ecr.us-east-1.amazonaws.com/myapp-php-dev:rv1'
    cpu_shares: 100
    mem_limit: 262144000
    build: .
    restart: always
    working_dir: /var/www
    volumes_from:
      - code

   code:
    image: busybox
    tty: true
    volumes:
      - /www:/var/www
Dockerfile:

FROM php:7.1-fpm

RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

COPY conf/php.ini /etc/php/7.1/fpm/conf.d/40-custom.ini
Conf/nginx.Conf:

user root;
worker_processes 1;
# daemon off;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  log_format main '$remote_addr - $remote_user [$time_local] "$request" '
          '$status $body_bytes_sent "$http_referer" '
          '"$http_user_agent" "$http_x_forwarded_for"';

  access_log /var/log/nginx/access.log main;

  sendfile on;
  tcp_nopush on;

  keepalive_timeout 65;

  gzip on;

  include /etc/nginx/conf.d/*;
}
Conf/php.ini:

; Enable XDebug
zend_extension = xdebug.so

; XDebug configuration
xdebug.remote_enable = 1
xdebug.renite_enable = 1
xdebug.max_nesting_level = 1000
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/var/log"
date.timezone = "America/New_York"
; Show PHP errors
display_errors = 1
Conf/supervisord.Conf:

[主管] nodaemon=true

[program:nginx]
command = /usr/sbin/nginx
user = root
autostart = true

[program:php7-fpm]
command = /usr/sbin/php-fpm7.0 -FR
user = root
autostart = true
站点/default.vhost:

server {
  server_name default;
  root        /var/www/default;
  index       index.html index.php;

  client_max_body_size 100M;
  fastcgi_read_timeout 1800;

  location / {
    try_files $uri $uri/ /index.php$is_args$args;
  }

  location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires       max;
    log_not_found off;
    access_log    off;
  }

  location ~ \.php$ {
    try_files     $uri =404;
    include       fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass  php:9000;
  }
}
问题似乎在于aws-compose.yml中“web”服务的卷部分中的引用,因为当我完全删除它们时,容器启动,但显示默认的Nginx“需要配置”保留页。在现场使用,如下所示:

    volumes:
      - /sites:/etc/nginx/conf.d
      - /conf/nginx.conf:/etc/nginx/nginx.conf
我在AWS ECS的任务部分的“已停止”下发现以下错误:

状态原因CannotStartContainerError:来自守护程序的错误响应:OCI运行时创建失败:container_linux.go:345:启动容器进程导致“process_linux.go:424:container init result\”rootfs_linux.go:58:mounting\\“/conf/nginx.conf\\”到rootfs\\”

有关我的本地docker-compose.yml文件中的信息,参考如下:

Root
--conf
  nginx.conf
  php.ini
  supervisord.conf
--logs
--sites
  default.vhost
--www
  --default
    index.php
aws-compose.yml
docker-compose.yml
Dockerfile
  - ./sites:/etc/nginx/conf.d
  - ./conf/nginx.conf:/etc/nginx/nginx.conf
但是,当我在AWS上旋转它时,会出现错误,说明语法不符合所需的正则表达式模式


有人能帮忙吗?

有人能回答吗?有人能回答吗?