Rather than conflict with the unexposed task model, change the names of
the object-oriented task display to `docker <object> ps`. The command
works identically to `docker service tasks`. This change is superficial.
This provides a more sensical docker experience while not trampling on
the task model that may be introduced as a top-level command at a later
date.
The following is an example of the display using `docker service ps`
with a service named `condescending_cori`:
```
$ docker service ps condescending_cori
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE
e2cd9vqb62qjk38lw65uoffd2 condescending_cori.1 condescending_cori alpine Running 13 minutes ago Running 6c6d232a5d0e
```
The following shows the output for the node on which the command is
running:
```console
$ docker node ps self
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE
b1tpbi43k1ibevg2e94bmqo0s mad_kalam.1 mad_kalam apline Accepted 2 seconds ago Accepted 6c6d232a5d0e
e2cd9vqb62qjk38lw65uoffd2 condescending_cori.1 condescending_cori alpine Running 12 minutes ago Running 6c6d232a5d0e
4x609m5o0qyn0kgpzvf0ad8x5 furious_davinci.1 furious_davinci redis Running 32 minutes ago Running 6c6d232a5d0e
```
Signed-off-by: Stephen J Day <stephen.day@docker.com>
(cherry picked from commit 0aa4e1e68973ede0c73f8a4356e2a17fc903f549)
| ... | ... |
@@ -28,7 +28,7 @@ func NewNodeCommand(dockerCli *client.DockerCli) *cobra.Command {
|
| 28 | 28 |
newListCommand(dockerCli), |
| 29 | 29 |
newPromoteCommand(dockerCli), |
| 30 | 30 |
newRemoveCommand(dockerCli), |
| 31 |
- newTasksCommand(dockerCli), |
|
| 31 |
+ newPSCommand(dockerCli), |
|
| 32 | 32 |
newUpdateCommand(dockerCli), |
| 33 | 33 |
) |
| 34 | 34 |
return cmd |
| 35 | 35 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,63 @@ |
| 0 |
+package node |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "golang.org/x/net/context" |
|
| 4 |
+ |
|
| 5 |
+ "github.com/docker/docker/api/client" |
|
| 6 |
+ "github.com/docker/docker/api/client/idresolver" |
|
| 7 |
+ "github.com/docker/docker/api/client/task" |
|
| 8 |
+ "github.com/docker/docker/cli" |
|
| 9 |
+ "github.com/docker/docker/opts" |
|
| 10 |
+ "github.com/docker/engine-api/types" |
|
| 11 |
+ "github.com/spf13/cobra" |
|
| 12 |
+) |
|
| 13 |
+ |
|
| 14 |
+type psOptions struct {
|
|
| 15 |
+ nodeID string |
|
| 16 |
+ noResolve bool |
|
| 17 |
+ filter opts.FilterOpt |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
| 21 |
+ opts := psOptions{filter: opts.NewFilterOpt()}
|
|
| 22 |
+ |
|
| 23 |
+ cmd := &cobra.Command{
|
|
| 24 |
+ Use: "ps [OPTIONS] self|NODE", |
|
| 25 |
+ Short: "List tasks running on a node", |
|
| 26 |
+ Args: cli.ExactArgs(1), |
|
| 27 |
+ RunE: func(cmd *cobra.Command, args []string) error {
|
|
| 28 |
+ opts.nodeID = args[0] |
|
| 29 |
+ return runPS(dockerCli, opts) |
|
| 30 |
+ }, |
|
| 31 |
+ } |
|
| 32 |
+ flags := cmd.Flags() |
|
| 33 |
+ flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") |
|
| 34 |
+ flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") |
|
| 35 |
+ |
|
| 36 |
+ return cmd |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+func runPS(dockerCli *client.DockerCli, opts psOptions) error {
|
|
| 40 |
+ client := dockerCli.Client() |
|
| 41 |
+ ctx := context.Background() |
|
| 42 |
+ |
|
| 43 |
+ nodeRef, err := Reference(client, ctx, opts.nodeID) |
|
| 44 |
+ if err != nil {
|
|
| 45 |
+ return nil |
|
| 46 |
+ } |
|
| 47 |
+ node, _, err := client.NodeInspectWithRaw(ctx, nodeRef) |
|
| 48 |
+ if err != nil {
|
|
| 49 |
+ return err |
|
| 50 |
+ } |
|
| 51 |
+ |
|
| 52 |
+ filter := opts.filter.Value() |
|
| 53 |
+ filter.Add("node", node.ID)
|
|
| 54 |
+ tasks, err := client.TaskList( |
|
| 55 |
+ ctx, |
|
| 56 |
+ types.TaskListOptions{Filter: filter})
|
|
| 57 |
+ if err != nil {
|
|
| 58 |
+ return err |
|
| 59 |
+ } |
|
| 60 |
+ |
|
| 61 |
+ return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve)) |
|
| 62 |
+} |
| 0 | 63 |
deleted file mode 100644 |
| ... | ... |
@@ -1,63 +0,0 @@ |
| 1 |
-package node |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "golang.org/x/net/context" |
|
| 5 |
- |
|
| 6 |
- "github.com/docker/docker/api/client" |
|
| 7 |
- "github.com/docker/docker/api/client/idresolver" |
|
| 8 |
- "github.com/docker/docker/api/client/task" |
|
| 9 |
- "github.com/docker/docker/cli" |
|
| 10 |
- "github.com/docker/docker/opts" |
|
| 11 |
- "github.com/docker/engine-api/types" |
|
| 12 |
- "github.com/spf13/cobra" |
|
| 13 |
-) |
|
| 14 |
- |
|
| 15 |
-type tasksOptions struct {
|
|
| 16 |
- nodeID string |
|
| 17 |
- noResolve bool |
|
| 18 |
- filter opts.FilterOpt |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-func newTasksCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
| 22 |
- opts := tasksOptions{filter: opts.NewFilterOpt()}
|
|
| 23 |
- |
|
| 24 |
- cmd := &cobra.Command{
|
|
| 25 |
- Use: "tasks [OPTIONS] self|NODE", |
|
| 26 |
- Short: "List tasks running on a node", |
|
| 27 |
- Args: cli.ExactArgs(1), |
|
| 28 |
- RunE: func(cmd *cobra.Command, args []string) error {
|
|
| 29 |
- opts.nodeID = args[0] |
|
| 30 |
- return runTasks(dockerCli, opts) |
|
| 31 |
- }, |
|
| 32 |
- } |
|
| 33 |
- flags := cmd.Flags() |
|
| 34 |
- flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") |
|
| 35 |
- flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") |
|
| 36 |
- |
|
| 37 |
- return cmd |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-func runTasks(dockerCli *client.DockerCli, opts tasksOptions) error {
|
|
| 41 |
- client := dockerCli.Client() |
|
| 42 |
- ctx := context.Background() |
|
| 43 |
- |
|
| 44 |
- nodeRef, err := Reference(client, ctx, opts.nodeID) |
|
| 45 |
- if err != nil {
|
|
| 46 |
- return nil |
|
| 47 |
- } |
|
| 48 |
- node, _, err := client.NodeInspectWithRaw(ctx, nodeRef) |
|
| 49 |
- if err != nil {
|
|
| 50 |
- return err |
|
| 51 |
- } |
|
| 52 |
- |
|
| 53 |
- filter := opts.filter.Value() |
|
| 54 |
- filter.Add("node", node.ID)
|
|
| 55 |
- tasks, err := client.TaskList( |
|
| 56 |
- ctx, |
|
| 57 |
- types.TaskListOptions{Filter: filter})
|
|
| 58 |
- if err != nil {
|
|
| 59 |
- return err |
|
| 60 |
- } |
|
| 61 |
- |
|
| 62 |
- return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve)) |
|
| 63 |
-} |
| ... | ... |
@@ -22,7 +22,7 @@ func NewServiceCommand(dockerCli *client.DockerCli) *cobra.Command {
|
| 22 | 22 |
cmd.AddCommand( |
| 23 | 23 |
newCreateCommand(dockerCli), |
| 24 | 24 |
newInspectCommand(dockerCli), |
| 25 |
- newTasksCommand(dockerCli), |
|
| 25 |
+ newPSCommand(dockerCli), |
|
| 26 | 26 |
newListCommand(dockerCli), |
| 27 | 27 |
newRemoveCommand(dockerCli), |
| 28 | 28 |
newScaleCommand(dockerCli), |
| 29 | 29 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,70 @@ |
| 0 |
+package service |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "golang.org/x/net/context" |
|
| 4 |
+ |
|
| 5 |
+ "github.com/docker/docker/api/client" |
|
| 6 |
+ "github.com/docker/docker/api/client/idresolver" |
|
| 7 |
+ "github.com/docker/docker/api/client/node" |
|
| 8 |
+ "github.com/docker/docker/api/client/task" |
|
| 9 |
+ "github.com/docker/docker/cli" |
|
| 10 |
+ "github.com/docker/docker/opts" |
|
| 11 |
+ "github.com/docker/engine-api/types" |
|
| 12 |
+ "github.com/spf13/cobra" |
|
| 13 |
+) |
|
| 14 |
+ |
|
| 15 |
+type psOptions struct {
|
|
| 16 |
+ serviceID string |
|
| 17 |
+ noResolve bool |
|
| 18 |
+ filter opts.FilterOpt |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 21 |
+func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
| 22 |
+ opts := psOptions{filter: opts.NewFilterOpt()}
|
|
| 23 |
+ |
|
| 24 |
+ cmd := &cobra.Command{
|
|
| 25 |
+ Use: "ps [OPTIONS] SERVICE", |
|
| 26 |
+ Short: "List the tasks of a service", |
|
| 27 |
+ Args: cli.ExactArgs(1), |
|
| 28 |
+ RunE: func(cmd *cobra.Command, args []string) error {
|
|
| 29 |
+ opts.serviceID = args[0] |
|
| 30 |
+ return runPS(dockerCli, opts) |
|
| 31 |
+ }, |
|
| 32 |
+ } |
|
| 33 |
+ flags := cmd.Flags() |
|
| 34 |
+ flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") |
|
| 35 |
+ flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") |
|
| 36 |
+ |
|
| 37 |
+ return cmd |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+func runPS(dockerCli *client.DockerCli, opts psOptions) error {
|
|
| 41 |
+ client := dockerCli.Client() |
|
| 42 |
+ ctx := context.Background() |
|
| 43 |
+ |
|
| 44 |
+ service, _, err := client.ServiceInspectWithRaw(ctx, opts.serviceID) |
|
| 45 |
+ if err != nil {
|
|
| 46 |
+ return err |
|
| 47 |
+ } |
|
| 48 |
+ |
|
| 49 |
+ filter := opts.filter.Value() |
|
| 50 |
+ filter.Add("service", service.ID)
|
|
| 51 |
+ if filter.Include("node") {
|
|
| 52 |
+ nodeFilters := filter.Get("node")
|
|
| 53 |
+ for _, nodeFilter := range nodeFilters {
|
|
| 54 |
+ nodeReference, err := node.Reference(client, ctx, nodeFilter) |
|
| 55 |
+ if err != nil {
|
|
| 56 |
+ return err |
|
| 57 |
+ } |
|
| 58 |
+ filter.Del("node", nodeFilter)
|
|
| 59 |
+ filter.Add("node", nodeReference)
|
|
| 60 |
+ } |
|
| 61 |
+ } |
|
| 62 |
+ |
|
| 63 |
+ tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter})
|
|
| 64 |
+ if err != nil {
|
|
| 65 |
+ return err |
|
| 66 |
+ } |
|
| 67 |
+ |
|
| 68 |
+ return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve)) |
|
| 69 |
+} |
| 0 | 70 |
deleted file mode 100644 |
| ... | ... |
@@ -1,70 +0,0 @@ |
| 1 |
-package service |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "golang.org/x/net/context" |
|
| 5 |
- |
|
| 6 |
- "github.com/docker/docker/api/client" |
|
| 7 |
- "github.com/docker/docker/api/client/idresolver" |
|
| 8 |
- "github.com/docker/docker/api/client/node" |
|
| 9 |
- "github.com/docker/docker/api/client/task" |
|
| 10 |
- "github.com/docker/docker/cli" |
|
| 11 |
- "github.com/docker/docker/opts" |
|
| 12 |
- "github.com/docker/engine-api/types" |
|
| 13 |
- "github.com/spf13/cobra" |
|
| 14 |
-) |
|
| 15 |
- |
|
| 16 |
-type tasksOptions struct {
|
|
| 17 |
- serviceID string |
|
| 18 |
- noResolve bool |
|
| 19 |
- filter opts.FilterOpt |
|
| 20 |
-} |
|
| 21 |
- |
|
| 22 |
-func newTasksCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
| 23 |
- opts := tasksOptions{filter: opts.NewFilterOpt()}
|
|
| 24 |
- |
|
| 25 |
- cmd := &cobra.Command{
|
|
| 26 |
- Use: "tasks [OPTIONS] SERVICE", |
|
| 27 |
- Short: "List the tasks of a service", |
|
| 28 |
- Args: cli.ExactArgs(1), |
|
| 29 |
- RunE: func(cmd *cobra.Command, args []string) error {
|
|
| 30 |
- opts.serviceID = args[0] |
|
| 31 |
- return runTasks(dockerCli, opts) |
|
| 32 |
- }, |
|
| 33 |
- } |
|
| 34 |
- flags := cmd.Flags() |
|
| 35 |
- flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") |
|
| 36 |
- flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") |
|
| 37 |
- |
|
| 38 |
- return cmd |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-func runTasks(dockerCli *client.DockerCli, opts tasksOptions) error {
|
|
| 42 |
- client := dockerCli.Client() |
|
| 43 |
- ctx := context.Background() |
|
| 44 |
- |
|
| 45 |
- service, _, err := client.ServiceInspectWithRaw(ctx, opts.serviceID) |
|
| 46 |
- if err != nil {
|
|
| 47 |
- return err |
|
| 48 |
- } |
|
| 49 |
- |
|
| 50 |
- filter := opts.filter.Value() |
|
| 51 |
- filter.Add("service", service.ID)
|
|
| 52 |
- if filter.Include("node") {
|
|
| 53 |
- nodeFilters := filter.Get("node")
|
|
| 54 |
- for _, nodeFilter := range nodeFilters {
|
|
| 55 |
- nodeReference, err := node.Reference(client, ctx, nodeFilter) |
|
| 56 |
- if err != nil {
|
|
| 57 |
- return err |
|
| 58 |
- } |
|
| 59 |
- filter.Del("node", nodeFilter)
|
|
| 60 |
- filter.Add("node", nodeReference)
|
|
| 61 |
- } |
|
| 62 |
- } |
|
| 63 |
- |
|
| 64 |
- tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter})
|
|
| 65 |
- if err != nil {
|
|
| 66 |
- return err |
|
| 67 |
- } |
|
| 68 |
- |
|
| 69 |
- return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve)) |
|
| 70 |
-} |
| 31 | 31 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,70 @@ |
| 0 |
+// +build experimental |
|
| 1 |
+ |
|
| 2 |
+package stack |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "fmt" |
|
| 6 |
+ |
|
| 7 |
+ "golang.org/x/net/context" |
|
| 8 |
+ |
|
| 9 |
+ "github.com/docker/docker/api/client" |
|
| 10 |
+ "github.com/docker/docker/api/client/idresolver" |
|
| 11 |
+ "github.com/docker/docker/api/client/task" |
|
| 12 |
+ "github.com/docker/docker/cli" |
|
| 13 |
+ "github.com/docker/docker/opts" |
|
| 14 |
+ "github.com/docker/engine-api/types" |
|
| 15 |
+ "github.com/docker/engine-api/types/swarm" |
|
| 16 |
+ "github.com/spf13/cobra" |
|
| 17 |
+) |
|
| 18 |
+ |
|
| 19 |
+type psOptions struct {
|
|
| 20 |
+ all bool |
|
| 21 |
+ filter opts.FilterOpt |
|
| 22 |
+ namespace string |
|
| 23 |
+ noResolve bool |
|
| 24 |
+} |
|
| 25 |
+ |
|
| 26 |
+func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
| 27 |
+ opts := psOptions{filter: opts.NewFilterOpt()}
|
|
| 28 |
+ |
|
| 29 |
+ cmd := &cobra.Command{
|
|
| 30 |
+ Use: "ps [OPTIONS] STACK", |
|
| 31 |
+ Short: "List the tasks in the stack", |
|
| 32 |
+ Args: cli.ExactArgs(1), |
|
| 33 |
+ RunE: func(cmd *cobra.Command, args []string) error {
|
|
| 34 |
+ opts.namespace = args[0] |
|
| 35 |
+ return runPS(dockerCli, opts) |
|
| 36 |
+ }, |
|
| 37 |
+ } |
|
| 38 |
+ flags := cmd.Flags() |
|
| 39 |
+ flags.BoolVarP(&opts.all, "all", "a", false, "Display all tasks") |
|
| 40 |
+ flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") |
|
| 41 |
+ flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") |
|
| 42 |
+ |
|
| 43 |
+ return cmd |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+func runPS(dockerCli *client.DockerCli, opts psOptions) error {
|
|
| 47 |
+ namespace := opts.namespace |
|
| 48 |
+ client := dockerCli.Client() |
|
| 49 |
+ ctx := context.Background() |
|
| 50 |
+ |
|
| 51 |
+ filter := opts.filter.Value() |
|
| 52 |
+ filter.Add("label", labelNamespace+"="+opts.namespace)
|
|
| 53 |
+ if !opts.all && !filter.Include("desired-state") {
|
|
| 54 |
+ filter.Add("desired-state", string(swarm.TaskStateRunning))
|
|
| 55 |
+ filter.Add("desired-state", string(swarm.TaskStateAccepted))
|
|
| 56 |
+ } |
|
| 57 |
+ |
|
| 58 |
+ tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter})
|
|
| 59 |
+ if err != nil {
|
|
| 60 |
+ return err |
|
| 61 |
+ } |
|
| 62 |
+ |
|
| 63 |
+ if len(tasks) == 0 {
|
|
| 64 |
+ fmt.Fprintf(dockerCli.Out(), "Nothing found in stack: %s\n", namespace) |
|
| 65 |
+ return nil |
|
| 66 |
+ } |
|
| 67 |
+ |
|
| 68 |
+ return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve)) |
|
| 69 |
+} |
| 0 | 70 |
deleted file mode 100644 |
| ... | ... |
@@ -1,70 +0,0 @@ |
| 1 |
-// +build experimental |
|
| 2 |
- |
|
| 3 |
-package stack |
|
| 4 |
- |
|
| 5 |
-import ( |
|
| 6 |
- "fmt" |
|
| 7 |
- |
|
| 8 |
- "golang.org/x/net/context" |
|
| 9 |
- |
|
| 10 |
- "github.com/docker/docker/api/client" |
|
| 11 |
- "github.com/docker/docker/api/client/idresolver" |
|
| 12 |
- "github.com/docker/docker/api/client/task" |
|
| 13 |
- "github.com/docker/docker/cli" |
|
| 14 |
- "github.com/docker/docker/opts" |
|
| 15 |
- "github.com/docker/engine-api/types" |
|
| 16 |
- "github.com/docker/engine-api/types/swarm" |
|
| 17 |
- "github.com/spf13/cobra" |
|
| 18 |
-) |
|
| 19 |
- |
|
| 20 |
-type tasksOptions struct {
|
|
| 21 |
- all bool |
|
| 22 |
- filter opts.FilterOpt |
|
| 23 |
- namespace string |
|
| 24 |
- noResolve bool |
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 |
-func newTasksCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
| 28 |
- opts := tasksOptions{filter: opts.NewFilterOpt()}
|
|
| 29 |
- |
|
| 30 |
- cmd := &cobra.Command{
|
|
| 31 |
- Use: "tasks [OPTIONS] STACK", |
|
| 32 |
- Short: "List the tasks in the stack", |
|
| 33 |
- Args: cli.ExactArgs(1), |
|
| 34 |
- RunE: func(cmd *cobra.Command, args []string) error {
|
|
| 35 |
- opts.namespace = args[0] |
|
| 36 |
- return runTasks(dockerCli, opts) |
|
| 37 |
- }, |
|
| 38 |
- } |
|
| 39 |
- flags := cmd.Flags() |
|
| 40 |
- flags.BoolVarP(&opts.all, "all", "a", false, "Display all tasks") |
|
| 41 |
- flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") |
|
| 42 |
- flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") |
|
| 43 |
- |
|
| 44 |
- return cmd |
|
| 45 |
-} |
|
| 46 |
- |
|
| 47 |
-func runTasks(dockerCli *client.DockerCli, opts tasksOptions) error {
|
|
| 48 |
- namespace := opts.namespace |
|
| 49 |
- client := dockerCli.Client() |
|
| 50 |
- ctx := context.Background() |
|
| 51 |
- |
|
| 52 |
- filter := opts.filter.Value() |
|
| 53 |
- filter.Add("label", labelNamespace+"="+opts.namespace)
|
|
| 54 |
- if !opts.all && !filter.Include("desired-state") {
|
|
| 55 |
- filter.Add("desired-state", string(swarm.TaskStateRunning))
|
|
| 56 |
- filter.Add("desired-state", string(swarm.TaskStateAccepted))
|
|
| 57 |
- } |
|
| 58 |
- |
|
| 59 |
- tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter})
|
|
| 60 |
- if err != nil {
|
|
| 61 |
- return err |
|
| 62 |
- } |
|
| 63 |
- |
|
| 64 |
- if len(tasks) == 0 {
|
|
| 65 |
- fmt.Fprintf(dockerCli.Out(), "Nothing found in stack: %s\n", namespace) |
|
| 66 |
- return nil |
|
| 67 |
- } |
|
| 68 |
- |
|
| 69 |
- return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve)) |
|
| 70 |
-} |
| ... | ... |
@@ -1573,7 +1573,7 @@ _docker_service() {
|
| 1573 | 1573 |
ls list |
| 1574 | 1574 |
rm remove |
| 1575 | 1575 |
scale |
| 1576 |
- tasks |
|
| 1576 |
+ ps |
|
| 1577 | 1577 |
update |
| 1578 | 1578 |
" |
| 1579 | 1579 |
__docker_subcommands "$subcommands" && return |
| ... | ... |
@@ -1667,7 +1667,7 @@ _docker_service_scale() {
|
| 1667 | 1667 |
esac |
| 1668 | 1668 |
} |
| 1669 | 1669 |
|
| 1670 |
-_docker_service_tasks() {
|
|
| 1670 |
+_docker_service_ps() {
|
|
| 1671 | 1671 |
local key=$(__docker_map_key_of_current_option '--filter|-f') |
| 1672 | 1672 |
case "$key" in |
| 1673 | 1673 |
desired-state) |
| ... | ... |
@@ -1941,7 +1941,7 @@ _docker_node() {
|
| 1941 | 1941 |
ls list |
| 1942 | 1942 |
promote |
| 1943 | 1943 |
rm remove |
| 1944 |
- tasks |
|
| 1944 |
+ ps |
|
| 1945 | 1945 |
update |
| 1946 | 1946 |
" |
| 1947 | 1947 |
__docker_subcommands "$subcommands" && return |
| ... | ... |
@@ -2038,7 +2038,7 @@ _docker_node_rm() {
|
| 2038 | 2038 |
esac |
| 2039 | 2039 |
} |
| 2040 | 2040 |
|
| 2041 |
-_docker_node_tasks() {
|
|
| 2041 |
+_docker_node_ps() {
|
|
| 2042 | 2042 |
local key=$(__docker_map_key_of_current_option '--filter|-f') |
| 2043 | 2043 |
case "$key" in |
| 2044 | 2044 |
desired-state) |
| ... | ... |
@@ -683,7 +683,7 @@ __docker_node_complete_ls_filters() {
|
| 683 | 683 |
return ret |
| 684 | 684 |
} |
| 685 | 685 |
|
| 686 |
-__docker_node_complete_tasks_filters() {
|
|
| 686 |
+__docker_node_complete_ps_filters() {
|
|
| 687 | 687 |
[[ $PREFIX = -* ]] && return 1 |
| 688 | 688 |
integer ret=1 |
| 689 | 689 |
|
| ... | ... |
@@ -788,7 +788,7 @@ __docker_node_commands() {
|
| 788 | 788 |
"ls:List nodes in the swarm" |
| 789 | 789 |
"promote:Promote a node as manager in the swarm" |
| 790 | 790 |
"rm:Remove a node from the swarm" |
| 791 |
- "tasks:List tasks running on a node" |
|
| 791 |
+ "ps:List tasks running on a node" |
|
| 792 | 792 |
"update:Update a node" |
| 793 | 793 |
) |
| 794 | 794 |
_describe -t docker-node-commands "docker node command" _docker_node_subcommands |
| ... | ... |
@@ -835,7 +835,7 @@ __docker_node_subcommand() {
|
| 835 | 835 |
$opts_help \ |
| 836 | 836 |
"($help -)*:node:__docker_complete_worker_nodes" && ret=0 |
| 837 | 837 |
;; |
| 838 |
- (tasks) |
|
| 838 |
+ (ps) |
|
| 839 | 839 |
_arguments $(__docker_arguments) \ |
| 840 | 840 |
$opts_help \ |
| 841 | 841 |
"($help -a --all)"{-a,--all}"[Display all instances]" \
|
| ... | ... |
@@ -844,7 +844,7 @@ __docker_node_subcommand() {
|
| 844 | 844 |
"($help -)1:node:__docker_complete_nodes" && ret=0 |
| 845 | 845 |
case $state in |
| 846 | 846 |
(filter-options) |
| 847 |
- __docker_node_complete_tasks_filters && ret=0 |
|
| 847 |
+ __docker_node_complete_ps_filters && ret=0 |
|
| 848 | 848 |
;; |
| 849 | 849 |
esac |
| 850 | 850 |
;; |
| ... | ... |
@@ -971,7 +971,7 @@ __docker_service_complete_ls_filters() {
|
| 971 | 971 |
return ret |
| 972 | 972 |
} |
| 973 | 973 |
|
| 974 |
-__docker_service_complete_tasks_filters() {
|
|
| 974 |
+__docker_service_complete_ps_filters() {
|
|
| 975 | 975 |
[[ $PREFIX = -* ]] && return 1 |
| 976 | 976 |
integer ret=1 |
| 977 | 977 |
|
| ... | ... |
@@ -1061,7 +1061,7 @@ __docker_service_commands() {
|
| 1061 | 1061 |
"ls:List services" |
| 1062 | 1062 |
"rm:Remove a service" |
| 1063 | 1063 |
"scale:Scale one or multiple services" |
| 1064 |
- "tasks:List the tasks of a service" |
|
| 1064 |
+ "ps:List the tasks of a service" |
|
| 1065 | 1065 |
"update:Update a service" |
| 1066 | 1066 |
) |
| 1067 | 1067 |
_describe -t docker-service-commands "docker service command" _docker_service_subcommands |
| ... | ... |
@@ -1149,7 +1149,7 @@ __docker_service_subcommand() {
|
| 1149 | 1149 |
;; |
| 1150 | 1150 |
esac |
| 1151 | 1151 |
;; |
| 1152 |
- (tasks) |
|
| 1152 |
+ (ps) |
|
| 1153 | 1153 |
_arguments $(__docker_arguments) \ |
| 1154 | 1154 |
$opts_help \ |
| 1155 | 1155 |
"($help -a --all)"{-a,--all}"[Display all tasks]" \
|
| ... | ... |
@@ -1158,7 +1158,7 @@ __docker_service_subcommand() {
|
| 1158 | 1158 |
"($help -)1:service:__docker_complete_services" && ret=0 |
| 1159 | 1159 |
case $state in |
| 1160 | 1160 |
(filter-options) |
| 1161 |
- __docker_service_complete_tasks_filters && ret=0 |
|
| 1161 |
+ __docker_service_complete_ps_filters && ret=0 |
|
| 1162 | 1162 |
;; |
| 1163 | 1163 |
esac |
| 1164 | 1164 |
;; |
| ... | ... |
@@ -115,7 +115,7 @@ read the [`dockerd`](dockerd.md) reference page. |
| 115 | 115 |
| [node demote](node_demote.md) | Demotes an existing manager so that it is no longer a manager | |
| 116 | 116 |
| [node inspect](node_inspect.md) | Inspect a node in the swarm | |
| 117 | 117 |
| [node update](node_update.md) | Update attributes for a node | |
| 118 |
-| [node tasks](node_tasks.md) | List tasks running on a node | |
|
| 118 |
+| [node ps](node_ps.md) | List tasks running on a node | |
|
| 119 | 119 |
| [node ls](node_ls.md) | List nodes in the swarm | |
| 120 | 120 |
| [node rm](node_rm.md) | Remove a node from the swarm | |
| 121 | 121 |
|
| ... | ... |
@@ -138,5 +138,5 @@ read the [`dockerd`](dockerd.md) reference page. |
| 138 | 138 |
| [service ls](service_ls.md) | List services in the swarm | |
| 139 | 139 |
| [service rm](service_rm.md) | Reemove a swervice from the swarm | |
| 140 | 140 |
| [service scale](service_scale.md) | Set the number of replicas for the desired state of the service | |
| 141 |
-| [service tasks](service_tasks.md) | List the tasks of a service | |
|
| 141 |
+| [service ps](service_ps.md) | List the tasks of a service | |
|
| 142 | 142 |
| [service update](service_update.md) | Update the attributes of a service | |
| 98 | 98 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,102 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "node ps" |
|
| 2 |
+description = "The node ps command description and usage" |
|
| 3 |
+keywords = ["node, tasks", "ps"] |
|
| 4 |
+aliases = ["/engine/reference/commandline/node_tasks/"] |
|
| 5 |
+[menu.main] |
|
| 6 |
+parent = "smn_cli" |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 10 |
+ |
|
| 11 |
+# node ps |
|
| 12 |
+ |
|
| 13 |
+```markdown |
|
| 14 |
+Usage: docker node ps [OPTIONS] self|NODE |
|
| 15 |
+ |
|
| 16 |
+List tasks running on a node |
|
| 17 |
+ |
|
| 18 |
+Options: |
|
| 19 |
+ -a, --all Display all instances |
|
| 20 |
+ -f, --filter value Filter output based on conditions provided |
|
| 21 |
+ --help Print usage |
|
| 22 |
+ --no-resolve Do not map IDs to Names |
|
| 23 |
+``` |
|
| 24 |
+ |
|
| 25 |
+Lists all the tasks on a Node that Docker knows about. You can filter using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section for more information about available filter options. |
|
| 26 |
+ |
|
| 27 |
+Example output: |
|
| 28 |
+ |
|
| 29 |
+ $ docker node ps swarm-manager1 |
|
| 30 |
+ ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 31 |
+ 7q92v0nr1hcgts2amcjyqg3pq redis.1 redis redis:3.0.6 Running 5 hours Running swarm-manager1 |
|
| 32 |
+ b465edgho06e318egmgjbqo4o redis.6 redis redis:3.0.6 Running 29 seconds Running swarm-manager1 |
|
| 33 |
+ bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 34 |
+ dkkual96p4bb3s6b10r7coxxt redis.9 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 35 |
+ 0tgctg8h8cech4w0k0gwrmr23 redis.10 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 36 |
+ |
|
| 37 |
+ |
|
| 38 |
+## Filtering |
|
| 39 |
+ |
|
| 40 |
+The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more |
|
| 41 |
+than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) |
|
| 42 |
+ |
|
| 43 |
+The currently supported filters are: |
|
| 44 |
+ |
|
| 45 |
+* [name](#name) |
|
| 46 |
+* [id](#id) |
|
| 47 |
+* [label](#label) |
|
| 48 |
+* [desired-state](#desired-state) |
|
| 49 |
+ |
|
| 50 |
+#### name |
|
| 51 |
+ |
|
| 52 |
+The `name` filter matches on all or part of a task's name. |
|
| 53 |
+ |
|
| 54 |
+The following filter matches all tasks with a name containing the `redis` string. |
|
| 55 |
+ |
|
| 56 |
+ $ docker node ps -f name=redis swarm-manager1 |
|
| 57 |
+ ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 58 |
+ 7q92v0nr1hcgts2amcjyqg3pq redis.1 redis redis:3.0.6 Running 5 hours Running swarm-manager1 |
|
| 59 |
+ b465edgho06e318egmgjbqo4o redis.6 redis redis:3.0.6 Running 29 seconds Running swarm-manager1 |
|
| 60 |
+ bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 61 |
+ dkkual96p4bb3s6b10r7coxxt redis.9 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 62 |
+ 0tgctg8h8cech4w0k0gwrmr23 redis.10 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 63 |
+ |
|
| 64 |
+ |
|
| 65 |
+#### id |
|
| 66 |
+ |
|
| 67 |
+The `id` filter matches a task's id. |
|
| 68 |
+ |
|
| 69 |
+ $ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1 |
|
| 70 |
+ ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 71 |
+ bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 72 |
+ |
|
| 73 |
+ |
|
| 74 |
+#### label |
|
| 75 |
+ |
|
| 76 |
+The `label` filter matches tasks based on the presence of a `label` alone or a `label` and a |
|
| 77 |
+value. |
|
| 78 |
+ |
|
| 79 |
+The following filter matches tasks with the `usage` label regardless of its value. |
|
| 80 |
+ |
|
| 81 |
+```bash |
|
| 82 |
+$ docker node ps -f "label=usage" |
|
| 83 |
+ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 84 |
+b465edgho06e318egmgjbqo4o redis.6 redis redis:3.0.6 Running 10 minutes Running swarm-manager1 |
|
| 85 |
+bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 9 minutes Running swarm-manager1 |
|
| 86 |
+``` |
|
| 87 |
+ |
|
| 88 |
+ |
|
| 89 |
+#### desired-state |
|
| 90 |
+ |
|
| 91 |
+The `desired-state` filter can take the values `running` and `accepted`. |
|
| 92 |
+ |
|
| 93 |
+ |
|
| 94 |
+## Related information |
|
| 95 |
+ |
|
| 96 |
+* [node inspect](node_inspect.md) |
|
| 97 |
+* [node update](node_update.md) |
|
| 98 |
+* [node ls](node_ls.md) |
|
| 99 |
+* [node rm](node_rm.md) |
| 42 | 42 |
deleted file mode 100644 |
| ... | ... |
@@ -1,101 +0,0 @@ |
| 1 |
-<!--[metadata]> |
|
| 2 |
-+++ |
|
| 3 |
-title = "node tasks" |
|
| 4 |
-description = "The node tasks command description and usage" |
|
| 5 |
-keywords = ["node, tasks"] |
|
| 6 |
-[menu.main] |
|
| 7 |
-parent = "smn_cli" |
|
| 8 |
-+++ |
|
| 9 |
-<![end-metadata]--> |
|
| 10 |
- |
|
| 11 |
-**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 12 |
- |
|
| 13 |
-# node tasks |
|
| 14 |
- |
|
| 15 |
-```markdown |
|
| 16 |
-Usage: docker node tasks [OPTIONS] self|NODE |
|
| 17 |
- |
|
| 18 |
-List tasks running on a node |
|
| 19 |
- |
|
| 20 |
-Options: |
|
| 21 |
- -a, --all Display all instances |
|
| 22 |
- -f, --filter value Filter output based on conditions provided |
|
| 23 |
- --help Print usage |
|
| 24 |
- --no-resolve Do not map IDs to Names |
|
| 25 |
-``` |
|
| 26 |
- |
|
| 27 |
-Lists all the tasks on a Node that Docker knows about. You can filter using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section for more information about available filter options. |
|
| 28 |
- |
|
| 29 |
-Example output: |
|
| 30 |
- |
|
| 31 |
- $ docker node tasks swarm-manager1 |
|
| 32 |
- ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 33 |
- 7q92v0nr1hcgts2amcjyqg3pq redis.1 redis redis:3.0.6 Running 5 hours Running swarm-manager1 |
|
| 34 |
- b465edgho06e318egmgjbqo4o redis.6 redis redis:3.0.6 Running 29 seconds Running swarm-manager1 |
|
| 35 |
- bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 36 |
- dkkual96p4bb3s6b10r7coxxt redis.9 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 37 |
- 0tgctg8h8cech4w0k0gwrmr23 redis.10 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 38 |
- |
|
| 39 |
- |
|
| 40 |
-## Filtering |
|
| 41 |
- |
|
| 42 |
-The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more |
|
| 43 |
-than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) |
|
| 44 |
- |
|
| 45 |
-The currently supported filters are: |
|
| 46 |
- |
|
| 47 |
-* [name](#name) |
|
| 48 |
-* [id](#id) |
|
| 49 |
-* [label](#label) |
|
| 50 |
-* [desired-state](#desired-state) |
|
| 51 |
- |
|
| 52 |
-#### name |
|
| 53 |
- |
|
| 54 |
-The `name` filter matches on all or part of a task's name. |
|
| 55 |
- |
|
| 56 |
-The following filter matches all tasks with a name containing the `redis` string. |
|
| 57 |
- |
|
| 58 |
- $ docker node tasks -f name=redis swarm-manager1 |
|
| 59 |
- ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 60 |
- 7q92v0nr1hcgts2amcjyqg3pq redis.1 redis redis:3.0.6 Running 5 hours Running swarm-manager1 |
|
| 61 |
- b465edgho06e318egmgjbqo4o redis.6 redis redis:3.0.6 Running 29 seconds Running swarm-manager1 |
|
| 62 |
- bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 63 |
- dkkual96p4bb3s6b10r7coxxt redis.9 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 64 |
- 0tgctg8h8cech4w0k0gwrmr23 redis.10 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 65 |
- |
|
| 66 |
- |
|
| 67 |
-#### id |
|
| 68 |
- |
|
| 69 |
-The `id` filter matches a task's id. |
|
| 70 |
- |
|
| 71 |
- $ docker node tasks -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1 |
|
| 72 |
- ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 73 |
- bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 5 seconds Running swarm-manager1 |
|
| 74 |
- |
|
| 75 |
- |
|
| 76 |
-#### label |
|
| 77 |
- |
|
| 78 |
-The `label` filter matches tasks based on the presence of a `label` alone or a `label` and a |
|
| 79 |
-value. |
|
| 80 |
- |
|
| 81 |
-The following filter matches tasks with the `usage` label regardless of its value. |
|
| 82 |
- |
|
| 83 |
-```bash |
|
| 84 |
-$ docker node tasks -f "label=usage" |
|
| 85 |
-ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 86 |
-b465edgho06e318egmgjbqo4o redis.6 redis redis:3.0.6 Running 10 minutes Running swarm-manager1 |
|
| 87 |
-bg8c07zzg87di2mufeq51a2qp redis.7 redis redis:3.0.6 Running 9 minutes Running swarm-manager1 |
|
| 88 |
-``` |
|
| 89 |
- |
|
| 90 |
- |
|
| 91 |
-#### desired-state |
|
| 92 |
- |
|
| 93 |
-The `desired-state` filter can take the values `running` and `accepted`. |
|
| 94 |
- |
|
| 95 |
- |
|
| 96 |
-## Related information |
|
| 97 |
- |
|
| 98 |
-* [node inspect](node_inspect.md) |
|
| 99 |
-* [node update](node_update.md) |
|
| 100 |
-* [node ls](node_ls.md) |
|
| 101 |
-* [node rm](node_rm.md) |
| ... | ... |
@@ -151,5 +151,5 @@ $ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
|
| 151 | 151 |
* [service ls](service_ls.md) |
| 152 | 152 |
* [service rm](service_rm.md) |
| 153 | 153 |
* [service scale](service_scale.md) |
| 154 |
-* [service tasks](service_tasks.md) |
|
| 154 |
+* [service ps](service_ps.md) |
|
| 155 | 155 |
* [service update](service_update.md) |
| ... | ... |
@@ -106,5 +106,5 @@ ID NAME REPLICAS IMAGE COMMAND |
| 106 | 106 |
* [service inspect](service_inspect.md) |
| 107 | 107 |
* [service rm](service_rm.md) |
| 108 | 108 |
* [service scale](service_scale.md) |
| 109 |
-* [service tasks](service_tasks.md) |
|
| 109 |
+* [service ps](service_ps.md) |
|
| 110 | 110 |
* [service update](service_update.md) |
| 111 | 111 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,102 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service ps" |
|
| 2 |
+description = "The service ps command description and usage" |
|
| 3 |
+keywords = ["service, tasks", "ps"] |
|
| 4 |
+aliases = ["/engine/reference/commandline/service_tasks/"] |
|
| 5 |
+[menu.main] |
|
| 6 |
+parent = "smn_cli" |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 10 |
+ |
|
| 11 |
+# service ps |
|
| 12 |
+ |
|
| 13 |
+```Markdown |
|
| 14 |
+Usage: docker service ps [OPTIONS] SERVICE |
|
| 15 |
+ |
|
| 16 |
+List the tasks of a service |
|
| 17 |
+ |
|
| 18 |
+Options: |
|
| 19 |
+ -a, --all Display all tasks |
|
| 20 |
+ -f, --filter value Filter output based on conditions provided |
|
| 21 |
+ --help Print usage |
|
| 22 |
+ --no-resolve Do not map IDs to Names |
|
| 23 |
+``` |
|
| 24 |
+ |
|
| 25 |
+Lists the tasks that are running as part of the specified service. This command |
|
| 26 |
+has to be run targeting a manager node. |
|
| 27 |
+ |
|
| 28 |
+ |
|
| 29 |
+## Examples |
|
| 30 |
+ |
|
| 31 |
+### Listing the tasks that are part of a service |
|
| 32 |
+ |
|
| 33 |
+The following command shows all the tasks that are part of the `redis` service: |
|
| 34 |
+ |
|
| 35 |
+```bash |
|
| 36 |
+$ docker service ps redis |
|
| 37 |
+ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 38 |
+0qihejybwf1x5vqi8lgzlgnpq redis.1 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 39 |
+bk658fpbex0d57cqcwoe3jthu redis.2 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 40 |
+5ls5s5fldaqg37s9pwayjecrf redis.3 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 41 |
+8ryt076polmclyihzx67zsssj redis.4 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 42 |
+1x0v8yomsncd6sbvfn0ph6ogc redis.5 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 43 |
+71v7je3el7rrw0osfywzs0lko redis.6 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 44 |
+4l3zm9b7tfr7cedaik8roxq6r redis.7 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 45 |
+9tfpyixiy2i74ad9uqmzp1q6o redis.8 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 46 |
+3w1wu13yuplna8ri3fx47iwad redis.9 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 47 |
+8eaxrb2fqpbnv9x30vr06i6vt redis.10 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 48 |
+``` |
|
| 49 |
+ |
|
| 50 |
+ |
|
| 51 |
+## Filtering |
|
| 52 |
+ |
|
| 53 |
+The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there |
|
| 54 |
+is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`). |
|
| 55 |
+Multiple filter flags are combined as an `OR` filter. For example, |
|
| 56 |
+`-f name=redis.1 -f name=redis.7` returns both `redis.1` and `redis.7` tasks. |
|
| 57 |
+ |
|
| 58 |
+The currently supported filters are: |
|
| 59 |
+ |
|
| 60 |
+* [id](#id) |
|
| 61 |
+* [name](#name) |
|
| 62 |
+* [desired-state](#desired-state) |
|
| 63 |
+ |
|
| 64 |
+ |
|
| 65 |
+#### ID |
|
| 66 |
+ |
|
| 67 |
+The `id` filter matches on all or a prefix of a task's ID. |
|
| 68 |
+ |
|
| 69 |
+```bash |
|
| 70 |
+$ docker service ps -f "id=8" redis |
|
| 71 |
+ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 72 |
+8ryt076polmclyihzx67zsssj redis.4 redis redis:3.0.6 Running 4 minutes Running worker1 |
|
| 73 |
+8eaxrb2fqpbnv9x30vr06i6vt redis.10 redis redis:3.0.6 Running 4 minutes Running manager1 |
|
| 74 |
+``` |
|
| 75 |
+ |
|
| 76 |
+#### Name |
|
| 77 |
+ |
|
| 78 |
+The `name` filter matches on task names. |
|
| 79 |
+ |
|
| 80 |
+```bash |
|
| 81 |
+$ docker service ps -f "name=redis.1" redis |
|
| 82 |
+ID NAME SERVICE IMAGE DESIRED STATE LAST STATE NODE |
|
| 83 |
+0qihejybwf1x5vqi8lgzlgnpq redis.1 redis redis:3.0.6 Running Running 8 seconds manager1 |
|
| 84 |
+``` |
|
| 85 |
+ |
|
| 86 |
+ |
|
| 87 |
+#### desired-state |
|
| 88 |
+ |
|
| 89 |
+The `desired-state` filter can take the values `running` and `accepted`. |
|
| 90 |
+ |
|
| 91 |
+ |
|
| 92 |
+## Related information |
|
| 93 |
+ |
|
| 94 |
+* [service create](service_create.md) |
|
| 95 |
+* [service inspect](service_inspect.md) |
|
| 96 |
+* [service ls](service_ls.md) |
|
| 97 |
+* [service rm](service_rm.md) |
|
| 98 |
+* [service scale](service_scale.md) |
|
| 99 |
+* [service update](service_update.md) |
| 81 | 81 |
deleted file mode 100644 |
| ... | ... |
@@ -1,101 +0,0 @@ |
| 1 |
-<!--[metadata]> |
|
| 2 |
-+++ |
|
| 3 |
-title = "service tasks" |
|
| 4 |
-description = "The service tasks command description and usage" |
|
| 5 |
-keywords = ["service, tasks"] |
|
| 6 |
-[menu.main] |
|
| 7 |
-parent = "smn_cli" |
|
| 8 |
-+++ |
|
| 9 |
-<![end-metadata]--> |
|
| 10 |
- |
|
| 11 |
-**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 12 |
- |
|
| 13 |
-# service tasks |
|
| 14 |
- |
|
| 15 |
-```Markdown |
|
| 16 |
-Usage: docker service tasks [OPTIONS] SERVICE |
|
| 17 |
- |
|
| 18 |
-List the tasks of a service |
|
| 19 |
- |
|
| 20 |
-Options: |
|
| 21 |
- -a, --all Display all tasks |
|
| 22 |
- -f, --filter value Filter output based on conditions provided |
|
| 23 |
- --help Print usage |
|
| 24 |
- --no-resolve Do not map IDs to Names |
|
| 25 |
-``` |
|
| 26 |
- |
|
| 27 |
-Lists the tasks that are running as part of the specified service. This command |
|
| 28 |
-has to be run targeting a manager node. |
|
| 29 |
- |
|
| 30 |
- |
|
| 31 |
-## Examples |
|
| 32 |
- |
|
| 33 |
-### Listing the tasks that are part of a service |
|
| 34 |
- |
|
| 35 |
-The following command shows all the tasks that are part of the `redis` service: |
|
| 36 |
- |
|
| 37 |
-```bash |
|
| 38 |
-$ docker service tasks redis |
|
| 39 |
-ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 40 |
-0qihejybwf1x5vqi8lgzlgnpq redis.1 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 41 |
-bk658fpbex0d57cqcwoe3jthu redis.2 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 42 |
-5ls5s5fldaqg37s9pwayjecrf redis.3 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 43 |
-8ryt076polmclyihzx67zsssj redis.4 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 44 |
-1x0v8yomsncd6sbvfn0ph6ogc redis.5 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 45 |
-71v7je3el7rrw0osfywzs0lko redis.6 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 46 |
-4l3zm9b7tfr7cedaik8roxq6r redis.7 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 47 |
-9tfpyixiy2i74ad9uqmzp1q6o redis.8 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 48 |
-3w1wu13yuplna8ri3fx47iwad redis.9 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 49 |
-8eaxrb2fqpbnv9x30vr06i6vt redis.10 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 50 |
-``` |
|
| 51 |
- |
|
| 52 |
- |
|
| 53 |
-## Filtering |
|
| 54 |
- |
|
| 55 |
-The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there |
|
| 56 |
-is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`). |
|
| 57 |
-Multiple filter flags are combined as an `OR` filter. For example, |
|
| 58 |
-`-f name=redis.1 -f name=redis.7` returns both `redis.1` and `redis.7` tasks. |
|
| 59 |
- |
|
| 60 |
-The currently supported filters are: |
|
| 61 |
- |
|
| 62 |
-* [id](#id) |
|
| 63 |
-* [name](#name) |
|
| 64 |
-* [desired-state](#desired-state) |
|
| 65 |
- |
|
| 66 |
- |
|
| 67 |
-#### ID |
|
| 68 |
- |
|
| 69 |
-The `id` filter matches on all or a prefix of a task's ID. |
|
| 70 |
- |
|
| 71 |
-```bash |
|
| 72 |
-$ docker service tasks -f "id=8" redis |
|
| 73 |
-ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 74 |
-8ryt076polmclyihzx67zsssj redis.4 redis redis:3.0.6 Running 4 minutes Running worker1 |
|
| 75 |
-8eaxrb2fqpbnv9x30vr06i6vt redis.10 redis redis:3.0.6 Running 4 minutes Running manager1 |
|
| 76 |
-``` |
|
| 77 |
- |
|
| 78 |
-#### Name |
|
| 79 |
- |
|
| 80 |
-The `name` filter matches on task names. |
|
| 81 |
- |
|
| 82 |
-```bash |
|
| 83 |
-$ docker service tasks -f "name=redis.1" redis |
|
| 84 |
-ID NAME SERVICE IMAGE DESIRED STATE LAST STATE NODE |
|
| 85 |
-0qihejybwf1x5vqi8lgzlgnpq redis.1 redis redis:3.0.6 Running Running 8 seconds manager1 |
|
| 86 |
-``` |
|
| 87 |
- |
|
| 88 |
- |
|
| 89 |
-#### desired-state |
|
| 90 |
- |
|
| 91 |
-The `desired-state` filter can take the values `running` and `accepted`. |
|
| 92 |
- |
|
| 93 |
- |
|
| 94 |
-## Related information |
|
| 95 |
- |
|
| 96 |
-* [service create](service_create.md) |
|
| 97 |
-* [service inspect](service_inspect.md) |
|
| 98 |
-* [service ls](service_ls.md) |
|
| 99 |
-* [service rm](service_rm.md) |
|
| 100 |
-* [service scale](service_scale.md) |
|
| 101 |
-* [service update](service_update.md) |
| ... | ... |
@@ -73,6 +73,6 @@ $ docker service update --limit-cpu 2 redis |
| 73 | 73 |
|
| 74 | 74 |
* [service create](service_create.md) |
| 75 | 75 |
* [service inspect](service_inspect.md) |
| 76 |
-* [service tasks](service_tasks.md) |
|
| 76 |
+* [service ps](service_ps.md) |
|
| 77 | 77 |
* [service ls](service_ls.md) |
| 78 | 78 |
* [service rm](service_rm.md) |
| ... | ... |
@@ -88,5 +88,5 @@ roll-back a task to a previous version of the service. |
| 88 | 88 |
* [service ls](../reference/commandline/service_ls.md) |
| 89 | 89 |
* [service rm](../reference/commandline/service_rm.md) |
| 90 | 90 |
* [service scale](../reference/commandline/service_scale.md) |
| 91 |
- * [service tasks](../reference/commandline/service_tasks.md) |
|
| 91 |
+ * [service ps](../reference/commandline/service_ps.md) |
|
| 92 | 92 |
* [service update](../reference/commandline/service_update.md) |
| ... | ... |
@@ -46,11 +46,11 @@ update](rolling-update.md) tutorial, start it now: |
| 46 | 46 |
c5uo6kdmzpon37mgj9mwglcfw |
| 47 | 47 |
``` |
| 48 | 48 |
|
| 49 |
-4. Run `docker service tasks redis` to see how the Swarm manager assigned the |
|
| 49 |
+4. Run `docker service ps redis` to see how the Swarm manager assigned the |
|
| 50 | 50 |
tasks to different nodes: |
| 51 | 51 |
|
| 52 | 52 |
```bash |
| 53 |
- $ docker service tasks redis |
|
| 53 |
+ $ docker service ps redis |
|
| 54 | 54 |
|
| 55 | 55 |
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
| 56 | 56 |
7q92v0nr1hcgts2amcjyqg3pq redis.1 redis redis:3.0.6 Running 26 seconds Running manager1 |
| ... | ... |
@@ -85,11 +85,11 @@ had a task assigned to it: |
| 85 | 85 |
|
| 86 | 86 |
The drained node shows `Drain` for `AVAILABILITY`. |
| 87 | 87 |
|
| 88 |
-7. Run `docker service tasks redis` to see how the Swarm manager updated the |
|
| 88 |
+7. Run `docker service ps redis` to see how the Swarm manager updated the |
|
| 89 | 89 |
task assignments for the `redis` service: |
| 90 | 90 |
|
| 91 | 91 |
```bash |
| 92 |
- $ docker service tasks redis |
|
| 92 |
+ $ docker service ps redis |
|
| 93 | 93 |
|
| 94 | 94 |
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
| 95 | 95 |
7q92v0nr1hcgts2amcjyqg3pq redis.1 redis redis:3.0.6 Running 4 minutes Running manager1 |
| ... | ... |
@@ -92,11 +92,11 @@ about a service in an easily readable format. |
| 92 | 92 |
] |
| 93 | 93 |
``` |
| 94 | 94 |
|
| 95 |
-4. Run `docker service tasks <SERVICE-ID>` to see which nodes are running the |
|
| 95 |
+4. Run `docker service ps <SERVICE-ID>` to see which nodes are running the |
|
| 96 | 96 |
service: |
| 97 | 97 |
|
| 98 | 98 |
``` |
| 99 |
- $ docker service tasks helloworld |
|
| 99 |
+ $ docker service ps helloworld |
|
| 100 | 100 |
|
| 101 | 101 |
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
| 102 | 102 |
8p1vev3fq5zm0mi8g0as41w35 helloworld.1 helloworld alpine Running 3 minutes Running worker2 |
| ... | ... |
@@ -106,10 +106,34 @@ desired state: |
| 106 | 106 |
Resources: |
| 107 | 107 |
``` |
| 108 | 108 |
|
| 109 |
-6. Run `docker service tasks <TASK-ID>` to watch the rolling update: |
|
| 109 |
+ The output of `service inspect` shows if your update paused due to failure: |
|
| 110 | 110 |
|
| 111 | 111 |
```bash |
| 112 |
- $ docker service tasks redis |
|
| 112 |
+ $ docker service inspect --pretty redis |
|
| 113 |
+ |
|
| 114 |
+ ID: 0u6a4s31ybk7yw2wyvtikmu50 |
|
| 115 |
+ Name: redis |
|
| 116 |
+ ...snip... |
|
| 117 |
+ Update status: |
|
| 118 |
+ State: paused |
|
| 119 |
+ Started: 11 seconds ago |
|
| 120 |
+ Message: update paused due to failure or early termination of task 9p7ith557h8ndf0ui9s0q951b |
|
| 121 |
+ ...snip... |
|
| 122 |
+ ``` |
|
| 123 |
+ |
|
| 124 |
+ To restart a paused update run `docker service update <SERVICE-ID>`. For example: |
|
| 125 |
+ |
|
| 126 |
+ ```bash |
|
| 127 |
+ docker service update redis |
|
| 128 |
+ ``` |
|
| 129 |
+ |
|
| 130 |
+ To avoid repeating certain update failures, you may need to reconfigure the |
|
| 131 |
+ service by passing flags to `docker service update`. |
|
| 132 |
+ |
|
| 133 |
+6. Run `docker service ps <SERVICE-ID>` to watch the rolling update: |
|
| 134 |
+ |
|
| 135 |
+ ```bash |
|
| 136 |
+ $ docker service ps redis |
|
| 113 | 137 |
|
| 114 | 138 |
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
| 115 | 139 |
dos1zffgeofhagnve8w864fco redis.1 redis redis:3.0.7 Running 37 seconds Running worker1 |
| ... | ... |
@@ -14,7 +14,7 @@ weight=18 |
| 14 | 14 |
# Scale the service in the swarm |
| 15 | 15 |
|
| 16 | 16 |
Once you have [deployed a service](deploy-service.md) to a swarm, you are ready |
| 17 |
-to use the Docker CLI to scale the number of service tasks in |
|
| 17 |
+to use the Docker CLI to scale the number of service ps in |
|
| 18 | 18 |
the swarm. |
| 19 | 19 |
|
| 20 | 20 |
1. If you haven't already, open a terminal and ssh into the machine where you |
| ... | ... |
@@ -36,10 +36,10 @@ service running in the swarm: |
| 36 | 36 |
helloworld scaled to 5 |
| 37 | 37 |
``` |
| 38 | 38 |
|
| 39 |
-3. Run `docker service tasks <SERVICE-ID>` to see the updated task list: |
|
| 39 |
+3. Run `docker service ps <SERVICE-ID>` to see the updated task list: |
|
| 40 | 40 |
|
| 41 | 41 |
``` |
| 42 |
- $ docker service tasks helloworld |
|
| 42 |
+ $ docker service ps helloworld |
|
| 43 | 43 |
|
| 44 | 44 |
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
| 45 | 45 |
8p1vev3fq5zm0mi8g0as41w35 helloworld.1 helloworld alpine Running 7 minutes Running worker2 |
| ... | ... |
@@ -20,7 +20,7 @@ func (s *DockerSwarmSuite) TestStackRemove(c *check.C) {
|
| 20 | 20 |
func (s *DockerSwarmSuite) TestStackTasks(c *check.C) {
|
| 21 | 21 |
d := s.AddDaemon(c, true, true) |
| 22 | 22 |
|
| 23 |
- stackArgs := append([]string{"tasks", "UNKNOWN_STACK"})
|
|
| 23 |
+ stackArgs := append([]string{"ps", "UNKNOWN_STACK"})
|
|
| 24 | 24 |
|
| 25 | 25 |
out, err := d.Cmd("stack", stackArgs...)
|
| 26 | 26 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -179,13 +179,13 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) {
|
| 179 | 179 |
|
| 180 | 180 |
filter := "name=redis-cluster" |
| 181 | 181 |
|
| 182 |
- out, err = d.Cmd("node", "tasks", "--filter", filter, "self")
|
|
| 182 |
+ out, err = d.Cmd("node", "ps", "--filter", filter, "self")
|
|
| 183 | 183 |
c.Assert(err, checker.IsNil) |
| 184 | 184 |
c.Assert(out, checker.Contains, name+".1") |
| 185 | 185 |
c.Assert(out, checker.Contains, name+".2") |
| 186 | 186 |
c.Assert(out, checker.Contains, name+".3") |
| 187 | 187 |
|
| 188 |
- out, err = d.Cmd("node", "tasks", "--filter", "name=none", "self")
|
|
| 188 |
+ out, err = d.Cmd("node", "ps", "--filter", "name=none", "self")
|
|
| 189 | 189 |
c.Assert(err, checker.IsNil) |
| 190 | 190 |
c.Assert(out, checker.Not(checker.Contains), name+".1") |
| 191 | 191 |
c.Assert(out, checker.Not(checker.Contains), name+".2") |