Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docker 1.13.0] "panic: runtime error: slice bounds out of range" when docker stats --format #30277

Closed
twang2218 opened this issue Jan 19, 2017 · 2 comments
Labels
area/cli kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/1.13

Comments

@twang2218
Copy link

Description

If no container is running on the host, then run the command docker stats --format 'table {{.Name}}' will cause panic.

Steps to reproduce the issue:

  1. Create a new docker host by docker-machine, or shutdown all the containers.
  2. Then run the following command
$ docker stats --format 'table {{.Name}}'

Describe the results you received:

 docker stats --format 'table {{.Name}}'
panic: runtime error: slice bounds out of range [recovered]
	panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0xade2e0, 0xc4200120e0)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
text/template.errRecover(0xc420165590)
	/usr/local/go/src/text/template/exec.go:140 +0x2ad
panic(0xade2e0, 0xc4200120e0)
	/usr/local/go/src/runtime/panic.go:458 +0x243
github.com/docker/docker/cli/command/formatter.(*containerStatsContext).Name(0xc4202d29a0, 0x0, 0x0)
	/usr/src/docker/.gopath/src/github.com/docker/docker/cli/command/formatter/stats.go:148 +0x86
reflect.Value.call(0xb5b9a0, 0xc4202d29a0, 0x2213, 0xba755f, 0x4, 0x1171478, 0x0, 0x0, 0x4da203, 0x1153920, ...)
	/usr/local/go/src/reflect/value.go:434 +0x5c8
reflect.Value.Call(0xb5b9a0, 0xc4202d29a0, 0x2213, 0x1171478, 0x0, 0x0, 0xc420026658, 0xb, 0xb)
	/usr/local/go/src/reflect/value.go:302 +0xa4
text/template.(*state).evalCall(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0xb5b9a0, 0xc4202d29a0, 0x2213, 0x1133d80, 0xc4203c4150, 0xc42039d2a3, ...)
	/usr/local/go/src/text/template/exec.go:658 +0x530
text/template.(*state).evalField(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0xc42039d2a3, 0x4, 0x1133d80, 0xc4203c4150, 0xc42039d2e0, 0x1, ...)
	/usr/local/go/src/text/template/exec.go:549 +0xdb6
text/template.(*state).evalFieldChain(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0xb5b9a0, 0xc4202d29a0, 0x16, 0x1133d80, 0xc4203c4150, 0xc42039d2d0, ...)
	/usr/local/go/src/text/template/exec.go:520 +0x22f
text/template.(*state).evalFieldNode(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0xc4203c4150, 0xc42039d2e0, 0x1, 0x1, 0x0, 0x0, ...)
	/usr/local/go/src/text/template/exec.go:484 +0x114
text/template.(*state).evalCommand(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0xc4203c4120, 0x0, 0x0, 0x0, 0xc4201653a8, 0x40d344, ...)
	/usr/local/go/src/text/template/exec.go:422 +0x866
text/template.(*state).evalPipeline(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0xc4201c7d60, 0xc41ffe1df2, 0xc420165440, 0x41430e)
	/usr/local/go/src/text/template/exec.go:400 +0xee
text/template.(*state).walk(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0x1133b40, 0xc4203c4180)
	/usr/local/go/src/text/template/exec.go:226 +0x423
text/template.(*state).walk(0xc420165510, 0xb5b9a0, 0xc4202d29a0, 0x16, 0x1133ea0, 0xc4203c40f0)
	/usr/local/go/src/text/template/exec.go:234 +0x13d
text/template.(*Template).execute(0xc420319b00, 0x11283a0, 0xc4203b6af0, 0xb5b9a0, 0xc4202d29a0, 0x0, 0x0)
	/usr/local/go/src/text/template/exec.go:189 +0x204
text/template.(*Template).Execute(0xc420319b00, 0x11283a0, 0xc4203b6af0, 0xb5b9a0, 0xc4202d29a0, 0x8, 0x0)
	/usr/local/go/src/text/template/exec.go:175 +0x53
github.com/docker/docker/cli/command/formatter.(*Context).postFormat(0xc4201c7c20, 0xc420319b00, 0x112e360, 0xc4202d29a0)
	/usr/src/docker/.gopath/src/github.com/docker/docker/cli/command/formatter/formatter.go:76 +0x2ab
github.com/docker/docker/cli/command/formatter.(*Context).Write(0xc4201c7c20, 0x112e360, 0xc4202d29a0, 0xc4203ab520, 0x0, 0xa9fc20)
	/usr/src/docker/.gopath/src/github.com/docker/docker/cli/command/formatter/formatter.go:121 +0x1bb
github.com/docker/docker/cli/command/formatter.ContainerStatsWrite(0x11289e0, 0xc4202ff320, 0x7ffcde78b87f, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/usr/src/docker/.gopath/src/github.com/docker/docker/cli/command/formatter/stats.go:133 +0x120
github.com/docker/docker/cli/command/container.runStats(0xc4201b9440, 0xc4203a61e0, 0x0, 0x0)
	/usr/src/docker/.gopath/src/github.com/docker/docker/cli/command/container/stats.go:217 +0xbac
github.com/docker/docker/cli/command/container.NewStatsCommand.func1(0xc4203a86c0, 0xc4203aa7a0, 0x0, 0x2, 0x0, 0x0)
	/usr/src/docker/.gopath/src/github.com/docker/docker/cli/command/container/stats.go:38 +0x6a
github.com/docker/docker/vendor/github.com/spf13/cobra.(*Command).execute(0xc4203a86c0, 0xc42000c1e0, 0x2, 0x2, 0xc4203a86c0, 0xc42000c1e0)
	/usr/src/docker/.gopath/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:646 +0x26d
github.com/docker/docker/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4200758c0, 0xc420075d40, 0xc42032ce90, 0xc420026448)
	/usr/src/docker/.gopath/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:742 +0x377
github.com/docker/docker/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4200758c0, 0xc4200758c0, 0x112a2e0)
	/usr/src/docker/.gopath/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:695 +0x2b
main.main()
	/usr/src/docker/.gopath/src/github.com/docker/docker/cmd/docker/docker.go:104 +0xcb

Describe the results you expected:

Should be the name field of the containers.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

$ docker version
Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:58:26 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:58:26 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.13.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-59-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 488.4 MiB
Name: d2
ID: 6HQG:3L5G:LZRG:YP2Z:4T36:CLD6:2K3X:ID7I:RWQE:KRJS:O6OE:CE2Y
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Labels:
 provider=digitalocean
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

I tested on both my local laptop with Docker for Mac 1.13.0-rc7 and brand new Digital Ocean droplet with Docker 1.13.0.

@AkihiroSuda AkihiroSuda added area/cli kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. and removed platform/desktop labels Jan 19, 2017
@yongtang
Copy link
Member

Added a PR #30281 to fix the issue.

@AkihiroSuda
Copy link
Member

Closing per #29702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/1.13
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants