Bird
0
0

You want to deploy a service with a constraint to run only on nodes labeled role=worker. Which option correctly applies this constraint?

hard📝 Workflow Q8 of 15
Docker - Swarm
You want to deploy a service with a constraint to run only on nodes labeled role=worker. Which option correctly applies this constraint?
Adocker service create --name app --filter 'role=worker' nginx
Bdocker service create --name app --label 'node.role=worker' nginx
Cdocker service create --name app --constraint 'node.labels.role == worker' nginx
Ddocker service create --name app --node-role worker nginx
Step-by-Step Solution
Solution:
  1. Step 1: Understand constraint syntax

    Constraints use --constraint with expression like 'node.labels.key == value'.
  2. Step 2: Evaluate options

    Only docker service create --name app --constraint 'node.labels.role == worker' nginx uses correct syntax; others misuse labels, filters, or flags.
  3. Final Answer:

    docker service create --name app --constraint 'node.labels.role == worker' nginx -> Option C
  4. Quick Check:

    Use --constraint with node.labels for placement [OK]
Quick Trick: Use --constraint 'node.labels.key == value' to control placement [OK]
Common Mistakes:
  • Using --label instead of --constraint
  • Trying --filter which is for listing, not placement
  • Using non-existent flags like --node-role

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes