To list all replicas of a service called nginx, which command should be used?

Prepare for the Docker Certified Associate test with our comprehensive quizzes that include key questions and detailed explanations. Ace your certification!

The command used to list all replicas of a service, such as nginx, is indeed "docker service ps nginx." This command provides information about the tasks associated with the specified service, including the state of each replica, whether it's running, failed, or pending.

By using this command, you can see detailed information about each replica, including where they are running, the current state, and their IDs. This is crucial for monitoring the health and performance of your service in a Docker Swarm environment.

In contrast, the other commands serve different purposes. For instance, "docker service ls" lists all the services currently running in the swarm but does not provide information on the specific replicas of a service. "docker container ls" lists currently running containers but does not relate directly to the service-level abstraction provided by Docker Swarm. Finally, "docker service inspect nginx" offers a detailed configuration of the service itself but does not enumerate the replicas or their current states.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy