docker stack ps (original) (raw)

Description List the tasks in the stack
Usage docker stack ps [OPTIONS] STACK

SwarmThis command works with the Swarm orchestrator.

Lists the tasks that are running as part of the specified stack.

Note

This is a cluster management command, and must be executed on a swarm manager node. To learn about managers and workers, refer to theSwarm mode section in the documentation.

Option Default Description
-f, --filter Filter output based on conditions provided
--format Format output using a custom template:'table': Print output in table format with column headers (default)'table TEMPLATE': Print output in table format using the given Go template'json': Print in JSON format'TEMPLATE': Print output using the given Go template.Refer tohttps://docs.docker.com/go/formatting/ for more information about formatting output with templates
--no-resolve Do not map IDs to Names
--no-trunc Do not truncate output
-q, --quiet Only display task IDs

List the tasks that are part of a stack

The following command shows all the tasks that are part of the voting stack:

Filtering (--filter)

The filtering flag (-f or --filter) format is a key=value pair. If there is more than one filter, then pass multiple flags (e.g. --filter "foo=bar" --filter "bif=baz"). Multiple filter flags are combined as an OR filter. For example,-f name=redis.1 -f name=redis.7 returns both redis.1 and redis.7 tasks.

The currently supported filters are:

id

The id filter matches on all or a prefix of a task's ID.

name

The name filter matches on task names.

node

The node filter matches on a node name or a node ID.

desired-state

The desired-state filter can take the values running, shutdown, ready or accepted.

Format the output (--format)

The formatting options (--format) pretty-prints tasks output using a Go template.

Valid placeholders for the Go template are listed below:

Placeholder Description
.ID Task ID
.Name Task name
.Image Task image
.Node Node ID
.DesiredState Desired state of the task (running, shutdown, or accepted)
.CurrentState Current state of the task
.Error Error
.Ports Task published ports

When using the --format option, the stack ps command will either output the data exactly as the template declares or, when using thetable directive, includes column headers as well.

The following example uses a template without headers and outputs theName and Image entries separated by a colon (:) for all tasks:

To list all tasks in JSON format, use the json directive:

Do not map IDs to Names (--no-resolve)

The --no-resolve option shows IDs for task name, without mapping IDs to Names.

Do not truncate output (--no-trunc)

When deploying a service, docker resolves the digest for the service's image, and pins the service to that digest. The digest is not shown by default, but is printed if --no-trunc is used. The --no-trunc option also shows the non-truncated task IDs, and error-messages, as can be seen below:

Only display task IDs (-q, --quiet)

The -q or --quiet option only shows IDs of the tasks in the stack. This example outputs all task IDs of the voting stack:

This option can be used to perform batch operations. For example, you can use the task IDs as input for other commands, such as docker inspect. The following example inspects all tasks of the voting stack: