Bird
0
0

Which of the following is the correct syntax to create a service with 3 replicas and publish port 80 to 8080?

easy📝 Syntax Q12 of 15
Docker - Swarm
Which of the following is the correct syntax to create a service with 3 replicas and publish port 80 to 8080?
Adocker service create --replicas 3 --publish 8080:80 myimage
Bdocker service create --publish 3 --replicas 80:8080 myimage
Cdocker service create --replicas=3 --publish=80:8080 myimage
Ddocker service create --replicas 3 --publish 80:8080 myimage
Step-by-Step Solution
Solution:
  1. Step 1: Check correct option format for replicas and publish

    The correct syntax uses --replicas 3 and --publish 8080:80 to map port 8080 on the host to port 80 in the container.
  2. Step 2: Validate port mapping order and syntax

    Port mapping is hostPort:containerPort, so 8080:80 is correct. Options B, C, and D have wrong order or syntax.
  3. Final Answer:

    docker service create --replicas 3 --publish 8080:80 myimage -> Option A
  4. Quick Check:

    Replicas and publish flags syntax = docker service create --replicas 3 --publish 8080:80 myimage [OK]
Quick Trick: Use --replicas N and --publish hostPort:containerPort [OK]
Common Mistakes:
  • Reversing port numbers in --publish
  • Using equal signs incorrectly
  • Mixing replicas and publish values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes