DCA practice question 23 of 25

You created a new service named 'http' and discover it is not registering as healthy. Will this command enable you to view the list of historical tasks for this service? Solution: 'docker ps http'

Full set: 191 questions
Answer options
A: Yes
B: No Correct answer
Correct Answer:
B. No
Explanation

The command docker ps http is incorrect for viewing the tasks of a Swarm service. The docker ps command lists running containers on the specific Docker host where the command is executed. It can filter this list, but it does not query the Swarm manager for service-related information, nor does it show historical (e.g., stopped or failed) containers by default. The correct command to view the current and historical tasks for a service named 'http' is docker service ps http. This command specifically queries the Swarm manager for the state of all tasks associated with that service across the entire cluster.

Why Incorrect

A. This is incorrect. docker ps operates on the local Docker daemon's containers, not on Swarm service tasks, and will not show historical tasks.

References

1. Docker Documentation, "docker service ps" CLI reference. The description states: "This command displays the tasks of a service. It provides information about the state of the tasks, and if they are running, on which node." (docs.docker.com/engine/reference/commandline/serviceps/)

2. Docker Documentation, "docker ps" CLI reference. The description states: "List containers." This command's scope is limited to the containers on a single node, not the abstract tasks of a Swarm service. (docs.docker.com/engine/reference/commandline/ps/)

Scroll to Top