0

I am currently trying to deploy a basic Hello World PHP application on Fargate. I have created the following Dockerfile:

FROM php:8.0-apache

ENV SRC_DIR /var/www/html

RUN mkdir -p $SRC_DIR
COPY hello.php $SRC_DIR
EXPOSE 80

The image then gets built and pushed to ECR. I have an ECS Fargate cluster that is then pulling the image from ECR and deploying it to an ALB target group configured for port 80. However, I am getting an error when the container is being deployed onto Fargate,

Below is the error Cloudwatch logs is providing:

[FATAL tini (7)] exec /var/www/html failed: Permission denied

Any advice on how to get this simple PHP app running in a healthy state would be appreciated.

Dave Michaels
  • 847
  • 1
  • 19
  • 51

1 Answers1

0

This isn't really an AWS/ECS/Fargate/ALB/TaskDefinition issue at all, it's a PHP/Docker/Apache question. You should be running this locally via docker run to test it before even attempting to do anything on AWS.

The error is telling you there is a Unix permissions error because the user that the Apache process runs as doesn't have access to the folder you created. This is because the commands in your Dockerfile are running as the root user.

One possible solution is to add a chmod command to your Dockerfile:

FROM php:8.0-apache

ENV SRC_DIR /var/www/html

RUN mkdir -p $SRC_DIR
COPY hello.php $SRC_DIR
chmod -R 644 $SRC_DIR
EXPOSE 80
Mark B
  • 183,023
  • 24
  • 297
  • 295