I am deploying a java app on aws ecs fargate in an aws account(aws-dev) and it is working perfectly fine. My app makes call to get the local host and able to resolve it.
InetAddress.getLocalHost()
On app startup, i printed contents of /etc/hosts and it looks like this:
127.0.0.1 localhost
10.111.11.111 ip-10-111-11-111.ec2.internal
Everything works fine till this point.
Now i got another aws account (aws-uat) and deployed the same app(same docker image) to ecs fargate but i am getting unknown host error.
java.net.UnknownHostException: 718ec01ffa6a11dea91ea43ea6d18328-1111111111: 718ec01ffa6a11dea91ea43ea6d18328-1111111111: System error
And reason for this error looks like is, /etc/hosts is different in this account. Here /etc/hosts content are as per mentioned below and hostname mapping is missing:
127.0.0.1 localhost
10.11.11.111
My question why container running from same docker image on aws ecs fargate would have different /etc/hosts and why hostname is not getting mapped to ip in later case ? Is this something related to aws networking between the 2 accounts, if yes what it could be and how to resolve it ? Or something else is wrong here ?
CodePudding user response:
You should check the DNS options in the VPC each of these is running in. I'm guessing you may have DNS Support or DNS Hostnames disabled in the second VPC.