ok, where i have to begin.
i have a local symfony && nginx configuration which works with docker without any problems. Now im trying to run this image in aws ecs service with launchtype ec2 and container port 8000.
docker-compose.yaml
services:
nginx:
image: mscam/symfony-demo-nginx:latest
build:
context: .
dockerfile: ./docker/nginx/Dockerfile
volumes:
- .:/var/www/html
# - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
# - ./docker/nginx/sites/:/etc/nginx/sites-available
# - ./docker/nginx/conf.d/:/etc/nginx/conf.d
depends_on:
- symfony
ports:
- "8000:8000"
symfony:
container_name: '${APP_NAME}-${APP_ENV}-backend'
build:
context: .
target: app_php
#restart: unless-stopped
ports:
- 9000:9000
both services have their own dockerfile which basic installs, nothing special.
Cloudwatch tell me the following:
2022-09-12T22:21:43.384+02:00 [12-Sep-2022 20:21:43] NOTICE: fpm is running, pid 7
2022-09-12T22:21:43.387+02:00 [12-Sep-2022 20:21:43] NOTICE: ready to handle connections
a few seconds later i get the message:
is unhealthy in target-group my-target-group due to (reason Health checks failed)
i guess, nginx is not really running but how i can found out this? Where i can start to troubleshoot this problem without any detailes error message?
Feel free to ask me for further informations if need. I dont know whats ineteresting at this point.
Dockerfile nginx:
FROM nginx:alpine
COPY . /var/www/html
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/nginx/sites/default.conf /etc/nginx/sites-available/default.conf
COPY ./docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
WORKDIR /var/www/html
CMD ["nginx"]
EXPOSE 8000
One idea... i tried with a demo where nginx is not specified as an extra service. Its all integrated in one service. maybe ecs cant find nginx in a multiple service container like docker-compose?
Taskdefinition:
{
"ipcMode": null,
"executionRoleArn":
"arn:aws:iam::000:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"dnsSearchDomains": [],
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "vv-xxx-backend",
"awslogs-region": "eu-central-1"
}
},
"entryPoint": [],
"portMappings": [
{
"hostPort": 0,
"protocol": "tcp",
"containerPort": 8000
},
{
"hostPort": 0,
"protocol": "tcp",
"containerPort": 80
}
],
"command": [],
"linuxParameters": null,
"cpu": 128,
"environment": [
{
"name": "APP_ENV",
"value": "dev"
}
],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": [],
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": [],
"memory": 496,
"memoryReservation": 300,
"volumesFrom": [],
"stopTimeout": null,
"image": "0000.dkr.ecr.eu-central-1.amazonaws.com/xx/xx:dev",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": [],
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": [],
"privileged": null,
"name": "symfony-backend"
}
],
"placementConstraints": [],
"memory": null,
"taskRoleArn": null,
"compatibilities": [
"EXTERNAL",
"EC2"
],
"taskDefinitionArn": "arn:aws:ecs:eu-central-1:xxx:task-definition/xxx:12",
"family": "vv-xxx-backend",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-ecr-pull"
}
],
"pidMode": null,
"requiresCompatibilities": [
"EC2"
],
"networkMode": null,
"runtimePlatform": null,
"cpu": null,
"revision": 12,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
nginx conf.d/default.conf
upstream php-upstream {
server symfony:9000;
}
nginx sites/default.conf
server {
listen 8000 default_server;
listen [::]:8000 default_server ipv6only=on;
server_name localhost;
root /var/www/html/public;
index index.php index.html index.htm;
real_ip_header X-Forwarded-For;
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REMOTE_ADDR $http_x_forwarded_for;
fastcgi_param DOCUMENT_ROOT $realpath_root;
#fixes timeouts
fastcgi_send_timeout 6000;
fastcgi_read_timeout 6000;
include fastcgi_params;
internal;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
}