label-schema / label-schema.org

Static content for Label Schema Spec
140 stars 16 forks source link

Add instructions for docker-compose.yml #9

Open lpalgarvio opened 7 years ago

lpalgarvio commented 7 years ago

As per https://docs.docker.com/compose/compose-file/

Example:

--
version: '2'
services:
  test:
    labels:
      - "org.label-schema.schema-version=1.0"
      - "org.label-schema.name=e.g. Example project name"
      - "org.label-schema.description=Example project description in 300 chars or less"
      - "org.label-schema.vendor=e.g. ACME Inc"
      - "org.label-schema.url=e.g. https://www.example.com/"
      - "org.label-schema.vcs-ref=$VCS_REF"
      - "org.label-schema.vcs-url=e.g. https://github.com/microscaling/microscaling"
      - "org.label-schema.version=$VERSION"
      - "org.label-schema.build-date=$BUILD_DATE"
rossf7 commented 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.

lpalgarvio commented 7 years ago

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.

lpalgarvio commented 7 years ago

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

lpalgarvio commented 7 years ago

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.