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

366
Visualizações
Docker placement preference vs Docker placement constraints

I am learning Docker. As part of my learning there is one topic I haven't understood. The usage of the Docker placement preferences when compared with constraints in Docker.

I have been keep searching in internet and asked many people everyone aware of the constraints not the preferences. I haven't found any good reference in internet. What is the use of placement preferences in Docker? When should I use them? Any sample example?

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

0

Placement prefs allow you to "spread" your replicas across nodes with certain tags, choosing to put the replicas as much "diverse" as possible.

Constraints will constrain (limit) the replicas to those nodes that match the constraint.

Image you have 4 servers in 2 datacenters (east, west) and some of the servers have an SSD drive, while others don't.

If you apply the following labels to the nodes:

node-1: datacenter=us-east, disk=ssd
node-2: datacenter=us-east, disk=ssd
node-3: datacenter=us-west, disk=sas
node-4: datacenter=us-west, disk=nl-sas

If you would deploy a service with 2 replicas and you want to provide geographic redundancy, you would start that service as follows:

docker service create \
  --replicas 2 \
  --name webserver \
  --placement-pref 'spread=node.labels.datacenter' \
  mywebservice:production

Docker Swarm would then try to "spread" the 2 replicas across both datacenters, so you'll end up with 1 replica on either node-1 or node-2, and the other replica on node-3 or node-4.

If you have a service (eg a reporting job) that does a lot of IOPS, you'll probably want to use your SSD equiped servers, so you'll place a constraint on the service:

docker service create \
  --constraint 'node.labels.disk == ssd' \
  myreporter:latest
over 4 years ago · Santiago Trujillo Relatório

0

Refer to "Control service placement" section in https://docs.docker.com/engine/swarm/services/

In short Placement constraint limits where a task can run (a task will not run on a node unless it satisfies the constraint, it will remain in pending state)

While placement constraints limit the nodes a service can run on, placement preferences try to place tasks on appropriate nodes in an algorithmic way (currently, only spread evenly). Placement preference helps you in distributing the tasks based on a constraint across the nodes.

e.g. placement constraint of node.region=east will let a task only run on nodes labelled "east" whereas, placement preference of node.region=east will help you spread the tasks across nodes evenly based node.region. If any node does not have this label, it will still get the task.

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