DCA · Question #46
After creating a new service named 'http', you notice that the new service is not registering as healthy. How do you view the list of historical tasks for that service by using the command line?
The correct answer is C. 'docker service ps http'. To view the historical and current tasks associated with a Docker Swarm service, including their status and any past failures, the docker service ps command is used.
Question
After creating a new service named 'http', you notice that the new service is not registering as healthy. How do you view the list of historical tasks for that service by using the command line?
Options
- A'docker inspect http'
- B'docker service inspect http'
- C'docker service ps http'
- D'docker ps http'
How the community answered
(28 responses)- A4% (1)
- C93% (26)
- D4% (1)
Why each option
To view the historical and current tasks associated with a Docker Swarm service, including their status and any past failures, the `docker service ps` command is used.
`docker inspect http` would attempt to inspect a container or image named 'http', not a service and its tasks.
`docker service inspect http` provides detailed low-level configuration information about the service itself, but it does not list its tasks or their historical states.
The command 'docker service ps http' displays the tasks (containers) associated with the 'http' service, including their current state, desired state, the node they ran on, and any error messages or exit codes. This provides a comprehensive historical view of task instances, which is essential for diagnosing why a service might not be healthy.
`docker ps http` lists running containers on the local daemon that match 'http', but does not show tasks belonging to a swarm service or historical tasks.
Concept tested: Docker Swarm service task inspection
Source: https://docs.docker.com/engine/reference/commandline/service_ps/
Topics
Community Discussion
No community discussion yet for this question.