How can you define what labels will be used for an image built using Docker Compose?

Experience Level: Senior
Tags: Docker Compose

Answer

Use labels: property of your service:

version: "3.9"
services:
  my-service:
    build:
      context: .
      labels:
      - com.example.description: "Our awesome service"
      - com.example.department: "IT"

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself