Search code examples
dockeramazon-ecsdocker-volumesumologic

How to share file or directory with other container on ECS?


I have a Sumologic log collector which is a generic log collector. I want the log collector to see logs and a config file from a different container. How do I accomplish this?


Solution

  • ECS containers can mount volumes so you would define

    {
        "containerDefinitions": [
            {
                "mountPoints": [
                  {
                    "sourceVolume": "logs",
                    "containerPath": "/tmp/clogs/"
                  },
            }
        ],
        "volumes": [
            {
                "name": "logs",
            }
        ]
    }
    

    ECS also has a nice UI you can click around to set up the volumes at the task definition level, and then the mounts at the container level.

    Once that's set up, ECS will mount a volume at the container path, and everything inside that path will be available to all other containers that mount the volume.

    Further reading: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_data_volumes.html