Edit: My first question was "how to link containers inside task definition on AWS ECS using Fargate?" But, may be I'm wrong from the start, so I changed my question and keep the content below:
I'm trying to deploy a simple Laravel based app on AWS via ECS. My service works as expected in local using docker-compose-yml file.
But on AWS I get: "nginx: [emerg] host not found in upstream "app" in /etc/nginx/conf.d/default.conf:12"
from my web container log.
Here the containers of my service: web (nginx), app (Laravel), database (MySQL) and cache (redis).
I understand that all containers of the task description share the same namespace, so there no need for linking container (we can't anyway use links attribute with Fargate).
May you help me finding the problem here? I'm blind.
Here my working local docker-compose.yml file:
version: '2'
services:
# The Application
app:
image: 696759765437.dkr.ecr.us-east-1.amazonaws.com/ali-
maison/tribe-migrate
volumes:
- /var/www/storage
env_file: '.env'
environment:
- "DB_HOST=database"
- "REDIS_HOST=cache"
# The Web Server
web:
image: 696759765437.dkr.ecr.us-east-1.amazonaws.com/ali-maison/laravel-web
ports:
- 80:80
# The Database
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=homestead"
- "MYSQL_PASSWORD=secret"
- "MYSQL_ROOT_PASSWORD=secret"
# redis
cache:
image: redis:3.0-alpine
volumes:
dbdata:
Here my web container Dockerfile:
FROM nginx:1.10
ADD vhost.conf /etc/nginx/conf.d/default.conf
WORKDIR /var/www
And my vhost.conf:
server {
listen 80;
index index.php index.html;
root /var/www/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
app:9000
with127.0.0.1:9000
– David Lin