Docker labels for ECS containers

amazon-ecsaws-clidocker

I'm new to using labels with Docker containers, but I noticed that the labels I add to my images during build are ignored by ECS when I deploy a task definition.

I can see that I can add the labels to the container as part of the task definition, but is there any way to make ECS respect the labels embedded in the image? Specifically, I would like to be able to see them when I inspect a running task.

Currently the task just lists "Docker labels – not configured" under the container's properties in the console, and doesn't include them when I use the CLI to describe the task-definition, service, or the running container instance.

Best Answer

From the official documentation of ECS docker volumes:

{
    "containerDefinitions": [
        {
            "mountPoints": [
                {
                    "sourceVolume": "string",
                    "containerPath": "/path/to/mount_volume",
                    "readOnly": boolean
                }
            ]
        }
    ],
    "volumes": [
        {
            "name": "string",
            "dockerVolumeConfiguration": {
                "scope": "string",
                "autoprovision": boolean,
                "driver": "string",
                "driverOpts": {
                    "key": "value"
                },
                "labels": {
                    "key": "value"
                }
            }
        }
    ]
}

What happens if you run the example above on a ECS task of yours?

Does your task include the "labels" item at the correct level (i.e. in the "volumes" section)?

This should actually be the same as issuing:

docker volume create --label YourLabel 

Cheers :)