douhuocuo9012 2018-08-17 23:12
浏览 396
已采纳

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

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条回答 默认 最新

  • dongquelu1239 2018-08-30 22:19
    关注

    I figured it out. Really stupid mistake actually. When I created Fargate configurations I used a Security Group without permissions to access some AWS components so the application was unable to boot.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大