Search code examples
amazon-web-servicesdockerdocker-composeamazon-ecs

Issue with ecs-searchdomain-sidecar in ECS with docker-compose


After deploying, I go to my cluster and I see my service and within my service the task. When I click on the task I have 2 containers:

  • my-app
  • App_ResolvConf_InitContainer

my-app is running and working as expected, but, the App_ResolvConf_InitContainer appears as STOPPED. When I expand it to see more information it shows:

The image: docker/ecs-searchdomain-sidecar:1.0

And in details: Exit Code 0 Command ["us-east-1.compute.internal","my-app.local"]

When I go to CloudWatch to check for logs there are no logs in this stream.

Context: I have my cluster in a private subnet. I created the NAT gateway in a public subnet and update the route table.

It doesn't seem to have issues pulling images. If I add redis to my compose file it pulls and creates the container

   redis:
     image: "redis:alpine"

This is my compose file:

version: "3.9"

services:
  web: 
    image: my-private-repo/web
    ports: ["80:80"]

When I search for docker/ecs-searchdomain-sidecar:1.0 I don't find information about this. Also, it doesn't provide any error. Just STOPPED.

I'm not receiving either any warning during docker compose up or docker compose convert.


Solution

  • The TL/DR version is that you should not worry about it and it's working as expected. You can ignore that sidecar.

    The longer version is that, because of how ECS service works, there are situations (dependent on the Linux image your main app container is based from) where plain service names cannot be resolved without the fully qualified domain names (e.g. web.local). That sidecar makes a trick at the local resolver level that enables web to be resolved in those situations. What you see is the sidecar making that trick and then exiting. It works as expected.