AWS ECR, ECS based deployment: nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/conf.d/default.conf:2

I am struggling to configure AWS ECS Task definition to run simple PHP-FPM & Nginx based containers.

My “app” container is running at app:9000 port and Nginx is in 80 port. Nginx is forwarding the request to app container through a fastcgi_pass app-upstream;

All of these are running perfectly in local. The same configuration is running perfectly in DigitalOcean Docker Instance but fails in AWS ECS.

I am guessing some task-definition configuration issue, but I can’t find it.

Error Logs:

I am getting this log from Nginx container

nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/conf.d/default.conf:2

enter image description here

and this log from App (PHP-FPM) container
enter image description here

ECS

I’ve created a simple cluster with T2 Small instance, which is running perfectly.

Dockerfile

In this Github Repo, I’ve added the Dockerfile for App, Nginx image, docker-compose.yml file and task-defination.json file for reference if there is any mistake in docker files.

Source code in Github repo: https://github.com/arifulhb/docker-ecr-sample

Expecting someone can help me out to fix this.

TIA

Ariful

Source: StackOverflow