Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

365
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda