Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

216
Visualizações
Specify service label in docker-compose file

When labeling a service in the docker-compose file only the created container is labeled and not the service itself.

I would like to add a label to a service created using a docker-compose file. When adding the label under the labels property, the label is only added to the corresponding container and not to the service itself.

In the documentation of the docker service create command there are two different options for labels:

  • --container-label: specify container label
  • --label: specify service label

I'm wondering why the label property in the docker-compose file only corresponds to the first option.

version: "3.7"

services:
  zalenium:
    image: zalenium:latest
    hostname: zalenium
    deploy:
      placement:
        constraints:
            - node.role == manager
    labels:
        - "de.zalando.gridRole=hub"
    ports:
        - "4444:4444"
    networks:
        - zalenium
    environment:
        - PULL_SELENIUM_IMAGE=true
        - ZALENIUM_PROXY_CLEANUP_TIMEOUT=1800
    command: ["start", "--swarmOverlayNetwork", "tau_zalenium", "--videoRecordingEnabled", "false"]

networks:
    zalenium:
        driver: overlay
        attachable: true

Actual result: Only the created container has the label "de.zalando.gridRole"

Expected result: The service should have the label "de.zalando.gridRole"

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

According to the docker-compose reference, you need to specify the service labels like this:

version: "3.7"
services:
  web:
    image: web
    deploy:
      labels:
        com.example.description: "This label will appear on the web service"

Add a deploy section and mention your labels there.

As with docker, here as well these labels are taken into account when deploying on a docker swarm. Otherwise they are ignored.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda