douhuocuo9012
douhuocuo9012
2018-08-17 23:12

Docker镜像在AWS Fargate上不起作用,但它在EC2中起作用

  • nginx
  • php
  • docker

I'm changing infrastructure on AWS and I want to use Docker (ECS) with Fargate. My Docker image is based on Ubuntu and I install all I need in it. I'm using Laravel 5.6 on NGINX running PHP 7.2. My Docker container works on my local machine and if I run ECS with EC2, however when I change to Fargate it returns NGINX 500 error. I did some tests and I know PHP is running, only when I install my Laravel app the error happens.

Since I cannot access Fargate machine I don't know how to debug. I tryied to connect NGINX with Loggly however it requires rsyslog and since I'm using Docker it cannot access Ubuntu's core. When I install and try to run it returns:

rsyslogd: imklog: cannot open kernel log (/proc/kmsg): Operation not permitted

Here is my Dockerfile:

FROM ubuntu:latest

ENV BACKEND_PATH=/code/Backend
ENV FRONTEND_PATH=/code/Frontend

## Update
RUN apt-get update -y

## Upgrade
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:certbot/certbot
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get dist-upgrade -y
RUN apt-get autoremove -y
RUN apt-get update -y

## Nano
RUN apt-get install -y nano

## Timezone
RUN echo "America/Sao_Paulo" > /etc/timezone && \
    apt-get install -y tzdata && \
    rm /etc/localtime && \
    ln -snf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata && \
    apt-get clean

## Git
RUN apt-get install -y git

## NGINX
RUN apt-get install -y nginx
COPY ./nginx/app/sites-available /etc/nginx/sites-available
COPY ./nginx/app/sites-available /etc/nginx/sites-enabled
COPY ./nginx/sites /etc/nginx/sites
COPY ./nginx/ssl /ssl

## PHP
RUN apt-get install -y php-cli php-fpm php-curl php-mbstring
COPY ./php/php.ini /usr/local/etc/php

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install libs
RUN apt-get install -y php-zip php-mysql php-gd pngquant gifsicle jpegoptim libicu-dev g++ php-intl php-xml

## Crontab
RUN apt-get install -y cron
COPY crontab newcrontab
RUN crontab newcrontab
RUN rm newcrontab

## Supervisor
RUN apt-get install -y supervisor
COPY ./supervisord /etc/supervisor/conf.d

## Certbot
RUN apt-get install -y python-certbot-nginx

## Install apps
COPY ./code/Backend /code/Backend
COPY ./code/Frontend/dist /code/Frontend/dist

RUN cd ${BACKEND_PATH} && chmod +x composer.phar && ./composer.phar self-update && php composer.phar install
RUN chmod -Rf 777 ${BACKEND_PATH}/storage
RUN chmod -Rf 777 ${BACKEND_PATH}/resources
RUN php ${BACKEND_PATH}/artisan config:clear
RUN php ${BACKEND_PATH}/artisan passport:keys

## Run!
EXPOSE 80 443

RUN service php7.2-fpm start
CMD ["/usr/bin/supervisord"]

I think this error has something to do with permissions but without error message it's almost impossible to know what's going on... Does anyone have any ideia how I may find this out?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答