Skip to content

single digit volume name leads to 'panic: runtime error: index out of range' #40550

@hacker-h

Description

@hacker-h

Description

Mounting a docker volume fails if its name is a single digit.

Steps to reproduce the issue:

  1. Run docker run -it --rm -v 1:/1 alpine

Describe the results you received:

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/docker/cli/cli/compose/loader.isFilePath(0xc42027e058, 0x1, 0x557dcb978c20)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cli/compose/loader/volume.go:121 +0x11c
github.com/docker/cli/cli/compose/loader.populateType(0xc4202ef200)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cli/compose/loader/volume.go:102 +0x77
github.com/docker/cli/cli/compose/loader.ParseVolume(0x7fff5f223efd, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cli/compose/loader/volume.go:44 +0x41d
github.com/docker/cli/cli/command/container.parse(0xc420540600, 0xc420414000, 0xc4202efb98, 0x0, 0x0)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cli/command/container/opts.go:336 +0x2be
github.com/docker/cli/cli/command/container.runRun(0x557dcae82cc0, 0xc4205098c0, 0xc420540600, 0xc420337f00, 0xc420414000, 0x557dcae543a0, 0x557dc92e7cc0)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cli/command/container/run.go:111 +0x481
github.com/docker/cli/cli/command/container.NewRunCommand.func1(0xc420421b80, 0xc4200d0500, 0x1, 0x5, 0x0, 0x0)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cli/command/container/run.go:48 +0x11e
github.com/docker/cli/vendor/github.com/spf13/cobra.(*Command).execute(0xc420421b80, 0xc4200d4020, 0x5, 0x5, 0xc420421b80, 0xc4200d4020)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/vendor/github.com/spf13/cobra/command.go:762 +0x46a
github.com/docker/cli/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42033a280, 0xc4205b7e00, 0x557dcab3caa0, 0xc4205b7e10)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/vendor/github.com/spf13/cobra/command.go:852 +0x30c
github.com/docker/cli/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42033a280, 0xc42033a280, 0x557dcae43c00)
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/vendor/github.com/spf13/cobra/command.go:800 +0x2d
main.main()
	/build/docker.io-4PLKn6/docker.io-18.09.7/.gopath/src/github.com/docker/cli/cmd/docker/docker.go:180 +0xde

Describe the results you expected:
Docker/moby should not crash.

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

Output of docker version:

Docker version 18.09.7, build 2d0083d

Output of docker info:

Containers: 19
 Running: 19
 Paused: 0
 Stopped: 0
Images: 22
Server Version: 18.09.7
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 
runc version: N/A
init version: v0.18.0 (expected: fec3683b971d9c3ef73f284f176672c44b448662)
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-135-generic
Operating System: Ubuntu 16.04.6 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.67GiB
Name: infrastructure-mature-goat
ID: 2FNS:W4TS:3HOL:52UA:D4RR:F774:AGH7:ITXO:QOPY:KMOT:5A3S:JT6P
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):
Virtual Machine (OpenStack)
Ubuntu 16.04.6 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliClientkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.version/18.09

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions