Reputation: 149
I'm creating a simple Spring API, which has a get call that returns some data. I put this in a docker container and tested the container on my localhost and it works (localhost:8080/getbooks returns a list of books). I then pushed this container to ECR and am running it on Fargate using a task.
My task is listed as RUNNING on a cluster in Fargate. However, when I try to access it via its public IP address (34.208.216.217:8080/getbooks), the request times out.
I've tried adding the port 8080 to the security group when creating the task (allowing everyone to access it), but this hasn't fixed anything.
Here's a picture of my task details, where I'm getting the public IP from: https://i.sstatic.net/VgE2r.jpg
I expect the running task to be accessible via the listed public IP, but it is not.
Upvotes: 12
Views: 6101
Reputation: 21
For anyone having this issue in the future:
After hours of modifying some heavy-duty settings trying to figure this out - my application in docker-compose was mapping 8080:8000
I changed this to be the same 8000:8000, pushed this new docker image and used this version for fargate cluster instance. The task definition then had 8000:8000 which worked!
Seem to have to be the same ports for host and container in fargate so make sure your application and container ports are the same
Upvotes: 0
Reputation: 430
You need to ensure that your container port is mapped to a host port correctly and that you have listed the host port in the security group. Fargate seems to default map your host port to be the same as your container port and makes the custom TCP port in the security group port 80.
Simple Solution:
Upvotes: 31
Reputation: 3765
Try modifying the application settings to something like:
server.address=0.0.0.0
And relaunch the task. The task is starting but probably bound to localhost which won't work under Fargate. 0.0.0.0 will tell it to bind to any ip address.
Upvotes: 1