- Newest
- Most votes
- Most comments
Hello,
Thank you for all provided information. It was really helpful in order to reproduce it from my side.
I have used a pretty similar configuration files and Dockerfiles to create my images. Please find below what I've used:
App Container
$ cat app/Dockerfile
FROM php:8.2-fpm
COPY index.php /var/www/html
$ cat app/index.php
<html>
<head>
<title>PHP Hello World!</title>
</head>
<body>
<?php echo '<h1>Hello World</h1>'; ?>
<?php phpinfo(); ?>
</body>
</html>
Nginx Container (All the same as you've shared except the app container port for configuration file)
$ cat nginx/default.conf
(...)
fastcgi_pass app:9000;
(...)
Task Definition:
{
"containerDefinitions": [
{
"name": "nginx",
"image": "<IMAGE>",
"memory": 256,
"cpu": 256,
"essential": true,
"mountPoints": [
{
"containerPath": "/var/www",
"sourceVolume": "my-vol"
}
],
"portMappings": [
{
"containerPort": 80,
"protocol": "tcp"
}
],
"links": [
"app"
]
},
{
"name": "app",
"image": "<IMAGE>",
"memory": 256,
"cpu": 256,
"essential": true,
"mountPoints": [
{
"containerPath": "/var/www",
"sourceVolume": "my-vol"
}
]
}
],
"volumes": [
{
"name": "my-vol",
"dockerVolumeConfiguration": {
"scope": "task",
"driver": "local"
}
}
],
"networkMode": "bridge",
"placementConstraints": [],
"family": "application-stack"
}
As you can see above, there are 2 differences mainly. One is about the application port and the other is the portMapping from app container that I've removed as it is not needed.
Regarding the application port, which I really think that is the issue here, checking the official php-fpm documentation, it informs that: By default, php-fpm will respond to CGI requests listening on localhost http port 9000.. Thus, this is the port that should be used while connecting from Nginx container to App container.
Hope this helps you to overcome the issue!

hi there, have you checked the links definition in CF docs? https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-containerdefinition.html#cfn-ecs-taskdefinition-containerdefinition-links it seems like you could avoid using it when both containers are placed in the same instance (which I see is your case given both containers are defined as part of the same task). Also have you tried setting fastcgi_pass localhost:8000 instead of app:8000? hope it helps narrowing it down a bit!
Yeah, I have tried with and without Links and using localhost instead of the container key, and I am still getting connection refused.
Did you figure this out? I'm having the same problem. I tried localhost:9000 as well as the container name with no luck.