Merge pull request #28029 from tealtail/27994-add-service-ls-truncate-opt

remove COMMAND column from `service ls` output. closes #27994
This commit is contained in:
Misty Stanley-Jones 2016-11-07 14:39:16 -08:00 committed by GitHub
commit c16860b649
6 changed files with 17 additions and 19 deletions

View file

@ -3,7 +3,6 @@ package service
import ( import (
"fmt" "fmt"
"io" "io"
"strings"
"text/tabwriter" "text/tabwriter"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -18,7 +17,7 @@ import (
) )
const ( const (
listItemFmt = "%s\t%s\t%s\t%s\t%s\n" listItemFmt = "%s\t%s\t%s\t%s\n"
) )
type listOptions struct { type listOptions struct {
@ -110,7 +109,7 @@ func printTable(out io.Writer, services []swarm.Service, running map[string]int)
// Ignore flushing errors // Ignore flushing errors
defer writer.Flush() defer writer.Flush()
fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "REPLICAS", "IMAGE", "COMMAND") fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "REPLICAS", "IMAGE")
for _, service := range services { for _, service := range services {
replicas := "" replicas := ""
if service.Spec.Mode.Replicated != nil && service.Spec.Mode.Replicated.Replicas != nil { if service.Spec.Mode.Replicated != nil && service.Spec.Mode.Replicated.Replicas != nil {
@ -124,8 +123,7 @@ func printTable(out io.Writer, services []swarm.Service, running map[string]int)
stringid.TruncateID(service.ID), stringid.TruncateID(service.ID),
service.Spec.Name, service.Spec.Name,
replicas, replicas,
service.Spec.TaskTemplate.ContainerSpec.Image, service.Spec.TaskTemplate.ContainerSpec.Image)
strings.Join(service.Spec.TaskTemplate.ContainerSpec.Args, " "))
} }
} }

View file

@ -74,7 +74,7 @@ $ docker service create --name redis redis:3.0.6
dmu1ept4cxcfe8k8lhtux3ro3 dmu1ept4cxcfe8k8lhtux3ro3
$ docker service ls $ docker service ls
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
dmu1ept4cxcf redis 1/1 redis:3.0.6 dmu1ept4cxcf redis 1/1 redis:3.0.6
``` ```
@ -98,7 +98,7 @@ number of `RUNNING` tasks is `3`:
```bash ```bash
$ docker service ls $ docker service ls
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
4cdgfyky7ozw redis 3/5 redis:3.0.7 4cdgfyky7ozw redis 3/5 redis:3.0.7
``` ```
@ -107,7 +107,7 @@ equal to the desired number:
```bash ```bash
$ docker service ls $ docker service ls
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
4cdgfyky7ozw redis 5/5 redis:3.0.7 4cdgfyky7ozw redis 5/5 redis:3.0.7
``` ```

View file

@ -46,7 +46,7 @@ For example, given the following service;
```bash ```bash
$ docker service ls $ docker service ls
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
dmu1ept4cxcf redis 3/3 redis:3.0.6 dmu1ept4cxcf redis 3/3 redis:3.0.6
``` ```

View file

@ -34,7 +34,7 @@ swarm.
On a manager node: On a manager node:
```bash ```bash
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
c8wgl7q4ndfd frontend 5/5 nginx:alpine c8wgl7q4ndfd frontend 5/5 nginx:alpine
dmu1ept4cxcf redis 3/3 redis:3.0.6 dmu1ept4cxcf redis 3/3 redis:3.0.6
``` ```
@ -60,7 +60,7 @@ The `id` filter matches all or part of a service's id.
```bash ```bash
$ docker service ls -f "id=0bcjw" $ docker service ls -f "id=0bcjw"
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
0bcjwfh8ychr redis 1/1 redis:3.0.6 0bcjwfh8ychr redis 1/1 redis:3.0.6
``` ```
@ -74,7 +74,7 @@ its value:
```bash ```bash
$ docker service ls --filter label=project $ docker service ls --filter label=project
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
01sl1rp6nj5u frontend2 1/1 nginx:alpine 01sl1rp6nj5u frontend2 1/1 nginx:alpine
36xvvwwauej0 frontend 5/5 nginx:alpine 36xvvwwauej0 frontend 5/5 nginx:alpine
74nzcxxjv6fq backend 3/3 redis:3.0.6 74nzcxxjv6fq backend 3/3 redis:3.0.6
@ -85,7 +85,7 @@ The following filter matches only services with the `project` label with the
```bash ```bash
$ docker service ls --filter label=project=project-a $ docker service ls --filter label=project=project-a
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
36xvvwwauej0 frontend 5/5 nginx:alpine 36xvvwwauej0 frontend 5/5 nginx:alpine
74nzcxxjv6fq backend 3/3 redis:3.0.6 74nzcxxjv6fq backend 3/3 redis:3.0.6
``` ```
@ -99,7 +99,7 @@ The following filter matches services with a name containing `redis`.
```bash ```bash
$ docker service ls --filter name=redis $ docker service ls --filter name=redis
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
0bcjwfh8ychr redis 1/1 redis:3.0.6 0bcjwfh8ychr redis 1/1 redis:3.0.6
``` ```

View file

@ -36,7 +36,7 @@ For example, to remove the redis service:
$ docker service rm redis $ docker service rm redis
redis redis
$ docker service ls $ docker service ls
ID NAME SCALE IMAGE COMMAND ID NAME SCALE IMAGE
``` ```
> **Warning**: Unlike `docker rm`, this command does not ask for confirmation > **Warning**: Unlike `docker rm`, this command does not ask for confirmation

View file

@ -28,8 +28,8 @@ Options:
### Scale a service ### Scale a service
The scale command enables you to scale one or more replicated services either up The scale command enables you to scale one or more replicated services either up
or down to the desired number of replicas. This command cannot be applied on or down to the desired number of replicas. This command cannot be applied on
services which are global mode. The command will return immediately, but the services which are global mode. The command will return immediately, but the
actual scaling of the service may take some time. To stop all replicas of a actual scaling of the service may take some time. To stop all replicas of a
service while keeping the service active in the swarm you can set the scale to 0. service while keeping the service active in the swarm you can set the scale to 0.
@ -56,7 +56,7 @@ replicas.
```bash ```bash
$ docker service ls --filter name=frontend $ docker service ls --filter name=frontend
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
3pr5mlvu3fh9 frontend 15/50 nginx:alpine 3pr5mlvu3fh9 frontend 15/50 nginx:alpine
``` ```
@ -80,7 +80,7 @@ backend scaled to 3
frontend scaled to 5 frontend scaled to 5
$ docker service ls $ docker service ls
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE
3pr5mlvu3fh9 frontend 5/5 nginx:alpine 3pr5mlvu3fh9 frontend 5/5 nginx:alpine
74nzcxxjv6fq backend 3/3 redis:3.0.6 74nzcxxjv6fq backend 3/3 redis:3.0.6
``` ```