문제
요거대로 ecs로 바로 올릴려하니 host not found in upstream "redash:5000" in /etc/nginx/conf.d/default.conf:2 에러 뜸

원인
https://www.appsloveworld.com/docker/100/14/aws-ecs-docker-nginx-emerg-host-not-found-in-upstream?expand_article=1
https://stackoverflow.com/questions/54772120/docker-links-with-awsvpc-network-mode
task_definition.json에서 "networkMode": "awsvpc"일때 links를 사용하지 못함.
aws fargate awsvpc 사용시에는 localhost로 통신이 가능다고 함.
해결책
docker exec -it redash_nginx_1 /bin/bash 해서 cat /etc/nginx/conf.d/default.conf
확인해보니 이렇게 되어있음. redash:5000 에러는 여기서 나나봄
upstream redash {
server redash:5000; -> localhost:5000 로 고침
}
server {
listen 80 default;
gzip on;
gzip_types *;
gzip_proxied any;
proxy_buffer_size 8k;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_pass <http://redash>;
}
}
Dockerfile을 요렇게 설정해놓고 build, aws ecr push
FROM redash/nginx:latest
COPY nginx.conf /etc/nginx/conf.d/default.conf
$ docker build . -t <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<repository_name>:<tag>
$ docker push 497217256558.dkr.ecr.ap-northeast-2.amazonaws.com/redash_ecs/nginx:latest
그 다음에 task_definition.json 의 nginx 컨테이너의 이미지 기존 redash/nginx:latest 를 497217256558.dkr.ecr.ap-northeast-2.amazonaws.com/redash_ecs/nginx:latest 요걸로 고침