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:
commit
c16860b649
6 changed files with 17 additions and 19 deletions
|
@ -3,7 +3,6 @@ package service
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
|
@ -18,7 +17,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
listItemFmt = "%s\t%s\t%s\t%s\t%s\n"
|
||||
listItemFmt = "%s\t%s\t%s\t%s\n"
|
||||
)
|
||||
|
||||
type listOptions struct {
|
||||
|
@ -110,7 +109,7 @@ func printTable(out io.Writer, services []swarm.Service, running map[string]int)
|
|||
// Ignore flushing errors
|
||||
defer writer.Flush()
|
||||
|
||||
fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "REPLICAS", "IMAGE", "COMMAND")
|
||||
fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "REPLICAS", "IMAGE")
|
||||
for _, service := range services {
|
||||
replicas := ""
|
||||
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),
|
||||
service.Spec.Name,
|
||||
replicas,
|
||||
service.Spec.TaskTemplate.ContainerSpec.Image,
|
||||
strings.Join(service.Spec.TaskTemplate.ContainerSpec.Args, " "))
|
||||
service.Spec.TaskTemplate.ContainerSpec.Image)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ $ docker service create --name redis redis:3.0.6
|
|||
dmu1ept4cxcfe8k8lhtux3ro3
|
||||
|
||||
$ docker service ls
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
dmu1ept4cxcf redis 1/1 redis:3.0.6
|
||||
```
|
||||
|
||||
|
@ -98,7 +98,7 @@ number of `RUNNING` tasks is `3`:
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
4cdgfyky7ozw redis 3/5 redis:3.0.7
|
||||
```
|
||||
|
||||
|
@ -107,7 +107,7 @@ equal to the desired number:
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
4cdgfyky7ozw redis 5/5 redis:3.0.7
|
||||
```
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ For example, given the following service;
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
dmu1ept4cxcf redis 3/3 redis:3.0.6
|
||||
```
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ swarm.
|
|||
|
||||
On a manager node:
|
||||
```bash
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
c8wgl7q4ndfd frontend 5/5 nginx:alpine
|
||||
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
|
||||
$ docker service ls -f "id=0bcjw"
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
0bcjwfh8ychr redis 1/1 redis:3.0.6
|
||||
```
|
||||
|
||||
|
@ -74,7 +74,7 @@ its value:
|
|||
|
||||
```bash
|
||||
$ docker service ls --filter label=project
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
01sl1rp6nj5u frontend2 1/1 nginx:alpine
|
||||
36xvvwwauej0 frontend 5/5 nginx:alpine
|
||||
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
|
||||
$ docker service ls --filter label=project=project-a
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
36xvvwwauej0 frontend 5/5 nginx:alpine
|
||||
74nzcxxjv6fq backend 3/3 redis:3.0.6
|
||||
```
|
||||
|
@ -99,7 +99,7 @@ The following filter matches services with a name containing `redis`.
|
|||
|
||||
```bash
|
||||
$ docker service ls --filter name=redis
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
0bcjwfh8ychr redis 1/1 redis:3.0.6
|
||||
```
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ For example, to remove the redis service:
|
|||
$ docker service rm redis
|
||||
redis
|
||||
$ docker service ls
|
||||
ID NAME SCALE IMAGE COMMAND
|
||||
ID NAME SCALE IMAGE
|
||||
```
|
||||
|
||||
> **Warning**: Unlike `docker rm`, this command does not ask for confirmation
|
||||
|
|
|
@ -28,8 +28,8 @@ Options:
|
|||
|
||||
### Scale a service
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
service while keeping the service active in the swarm you can set the scale to 0.
|
||||
|
@ -56,7 +56,7 @@ replicas.
|
|||
```bash
|
||||
$ docker service ls --filter name=frontend
|
||||
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
3pr5mlvu3fh9 frontend 15/50 nginx:alpine
|
||||
```
|
||||
|
||||
|
@ -80,7 +80,7 @@ backend scaled to 3
|
|||
frontend scaled to 5
|
||||
|
||||
$ docker service ls
|
||||
ID NAME REPLICAS IMAGE COMMAND
|
||||
ID NAME REPLICAS IMAGE
|
||||
3pr5mlvu3fh9 frontend 5/5 nginx:alpine
|
||||
74nzcxxjv6fq backend 3/3 redis:3.0.6
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue