What are my next steps for hosting my container(s)?

0

Hi,

First and foremost, I apologize for how stupid this question may be.

For the past week hours I've been researching how I could host my webapp on a cloud provider such as AWS given my circumstances, but haven't had any success. I promised myself I wouldn't ask the community, but I am giving up.

Localhost Setup

  • On my localhost, I have 3 containers:
    • Backend/API container
    • Frontend / React app container
    • Nginx container ( acts as a to route based on path)
  • When I run docker-compose up on my local machine, the app(s) come together to work as intended. For reference, I followed this guide and my source code is exactly the same.
  • My docker-compose is the following:
version: '3'

services:
  web:
    build: ./nginx
    ports:
      - "80:80"
    depends_on:
      - api
      - frontend
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
  
  api:
    image: platform-api:latest
    ports:
      - "8080:8080"
    env_file:
      - backend.env
  
  frontend:
    image: platform-frontend:latest
    ports:
      - "3000:3000"
    env_file:
      - frontend.env

AWS Setup (?)

  • I spent ALOT of time researching how I can host my app on AWS, but have just been going in a circle.
  • I've uploaded all 3 of my containers to ECR
    • Backend/API container
    • Frontend / React app container
    • Nginx reverse proxy container (to route based on path)
  • I've created task definitions with bridge mode so that I am able to link the containers together

The issues

  • When I create my cluster and service with my task definition, nothing seems to happen. The service just stays on provisioning and won't move.
    • Similarly, if I just tried just running 1 container, my backend container, it still gets stuck on provisioning
  • I've added a health check endpoint to my API that returns a 200 status code, but it still gets stuck on provisioning
  • I want to say that my setup isn't working because of a port-related issue, but I am not entirely sure what I can do to debug.

My questions

  1. I am using the bridge network mode as it seems it's the only way to link my containers together. Should I be usingawsvpc as the network mode? If so, how can I link/get the containers to talk to eachother on different ports?
  2. When using the bridge network mode, I set both the host & container port to 8080 as that how I run it on my local machine. Should I be doing this differently?

My overall goal

  • My overall goal is to have everything running under 1 domain and/or cluster. I plan on doing path based routing with a reverse proxy, which is why I have a 3rd nginx container, similar to this guide

What are the next steps I can do to get these containers and linked together? Is there a detailed tutorial or post on someone hosting on ECS with bridge mode?

I thank you in advanced for taking the time to read my lengthy post

Matthew
asked a month ago369 views
1 Answer
1

Hello.

I am using the bridge network mode as it seems it's the only way to link my containers together. Should I be usingawsvpc as the network mode? If so, how can I link/get the containers to talk to eachother on different ports?

It is possible to communicate even in "awsvpc" mode.
When using "awsvpc" mode, you need to place the container within the same task and communicate using "localhost:port number".
https://stackoverflow.com/questions/47637588/linking-container-in-aws-fargate

Alternatively, you can make the container a separate task and use something like Service Connect configuration.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect.html

When using "bridge" mode, the following tutorial may be helpful.
Since it uses the "link" setting, the container name and port number are required when connecting.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-nginx-ecs.html

When using the bridge network mode, I set both the host & container port to 8080 as that how I run it on my local machine. Should I be doing this differently?

If you want to use the same port for the host and container, it may be better to use host mode.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/networking-networkmode-host.html

profile picture
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions