Explorar o código

'docker list -n': display absolute layer IDs instead of names

Solomon Hykes %!s(int64=12) %!d(string=hai) anos
pai
achega
10ca2206e2
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      dockerd/dockerd.go

+ 8 - 1
dockerd/dockerd.go

@@ -229,6 +229,9 @@ func startCommand(cmd *exec.Cmd, interactive bool) (io.WriteCloser, io.ReadClose
 }
 
 func (docker *Docker) CmdList(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
+	flags := Subcmd(stdout, "list", "[OPTIONS]", "Show all containers")
+	numeric := flags.Bool("n", false, "Display absolute layer IDs instead of names")
+	flags.Parse(args)
 	var longestCol int
 	for _, container := range docker.containers {
 		if l := len(container.CmdString()); l > longestCol {
@@ -245,7 +248,11 @@ func (docker *Docker) CmdList(stdin io.ReadCloser, stdout io.Writer, args ...str
 	for _, container := range docker.containers {
 		var layers []string
 		for _, layer := range container.Layers {
-			layers = append(layers, layer.Name)
+			if *numeric {
+				layers = append(layers, layer.Id)
+			} else {
+				layers = append(layers, layer.Name)
+			}
 		}
 		fmt.Fprintf(stdout, tpl,
 			/* ID */	container.Id,