1

I have two containers I run on ECS. One container is an app which shares a config file via a docker volume to a second container which is a Sumologic file collector which is a generic logging container.

The issue I have is every once in a while the logging container will get an error Cannot find file /path/to/logging/file.json. The only reason this would happen is if the volume is empty, so the app container did not get to put the config file into the volume on time.

How do I get the app container to put files into a volume before a second container tries to read the files?

wonton
  • 7,568
  • 9
  • 56
  • 93

1 Answers1

1

As of March 2019 there a new ECS feature that solves this issue. The goal is to make sure the logging container doesn't start until the app container has started (which means that the app container has successfully mounted its files into the volume).

The way you do this is with dependsOn in your task definition. e.g. if you want a container to start only after a container foo has started, you do

"dependsOn": [
   {
       "containerName": "foo",
       "condition": "START"
   }
]

Further reading:

wonton
  • 7,568
  • 9
  • 56
  • 93