Open lpalgarvio opened 7 years ago
Thanks for raising this and I did some experimenting with the label support in Compose. These labels are added to the containers created by Compose. But they aren't added to any images built by Compose. To add labels to an image you need to add them in the Dockerfile.
V1 of label schema only covers build time labels. But runtime labels will be covered in a future version.
I like the idea of having a page with how to use label schema with widely used tools like Compose.
There is an issue for this in Docker Compose, https://github.com/docker/compose/issues/4038
The Docker Compose YAML file allows for building images with it, but is omitting the labels for images it builds, even though labels for Volumes and Networks are already supported.
Proposal: Support for building images with labels #4038 is fixed. This can now be implemented in the next Docker Compose 1.14 version, probably only for Docker Compose format version 3.0 or higher.
Support for Composer format 2.x is pending. Add support for build labels in 2.1 and 2.2 format #4863
This last issue has been fixed and closed. Add support for build labels in 2.1 and 2.2 format #4863
Labels can now be included in composer files for any kind of resource, including for builds.
As per https://docs.docker.com/compose/compose-file/
Example: