Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Volume creation fails when used in docker run command #840

Closed
matt-deboer opened this issue Dec 24, 2016 · 2 comments
Closed

Volume creation fails when used in docker run command #840

matt-deboer opened this issue Dec 24, 2016 · 2 comments

Comments

@matt-deboer
Copy link

Running the following command:

docker run --rm -it -v testvolume2:/data --volume-driver=vmdk alpine:3.4 sh

results in the following error:

docker: Error response from daemon: create testvolume2: Post http://%2Frun%2Fdocker%2Fplugins%2Fvmdk.sock/VolumeDriver.Create: http: ContentLength=35 with Body length 0.

Running docker volume create --name testvolume2 --driver vmdk first, and then running the above command succeeds normally.

Unfortunately, I'm using Mesos which creates its volumes using docker run and passing the --volume-driver flag

The following stack trace appears in the volume driver logs:

2016/12/24 04:15:01 http: panic serving @: assignment to entry in nil map
goroutine 333 [running]:
net/http.(*conn).serve.func1(0xc8202f2980)
	/usr/local/go/src/net/http/server.go:1389 +0xc1
panic(0x814de0, 0xc8202866e0)
	/usr/local/go/src/runtime/panic.go:426 +0x4e9
main.(*vmdkDriver).Create(0xc820195440, 0xc8202f41c0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/drone/src/github.com/vmware/docker-volume-vsphere/vmdk_plugin/plugin.go:214 +0x10f
github.com/vmware/docker-volume-vsphere/vendor/github.com/docker/go-plugins-helpers/volume.(*Handler).initMux.func1(0xc8202f41c0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/drone/src/github.com/vmware/docker-volume-vsphere/vendor/github.com/docker/go-plugins-helpers/volume/api.go:94 +0x7f
github.com/vmware/docker-volume-vsphere/vendor/github.com/docker/go-plugins-helpers/volume.(*Handler).handle.func1(0x7f1eec5dd758, 0xc820340270, 0xc8200c2380)
	/drone/src/github.com/vmware/docker-volume-vsphere/vendor/github.com/docker/go-plugins-helpers/volume/api.go:132 +0xde
net/http.HandlerFunc.ServeHTTP(0xc82030e790, 0x7f1eec5dd758, 0xc820340270, 0xc8200c2380)
	/usr/local/go/src/net/http/server.go:1618 +0x3a
net/http.(*ServeMux).ServeHTTP(0xc8202df440, 0x7f1eec5dd758, 0xc820340270, 0xc8200c2380)
	/usr/local/go/src/net/http/server.go:1910 +0x17d
net/http.serverHandler.ServeHTTP(0xc82021d000, 0x7f1eec5dd758, 0xc820340270, 0xc8200c2380)
	/usr/local/go/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc8202f2980)
	/usr/local/go/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2137 +0x44e

Environment:
Coreos 1185.2, running within a docker container, docker version 1.11.2
Release: (error occurs on both 0.8.1 and 0.9)

@pdhamdhere
Copy link
Contributor

Volume options map is nil with --volume-driver and thus panic. Following patch should address this;

--- a/vmdk_plugin/drivers/vmdk/vmdk_driver.go
+++ b/vmdk_plugin/drivers/vmdk/vmdk_driver.go
@@ -249,6 +249,9 @@ func (d *VolumeDriver) Create(r volume.Request) volume.Response {
 
        // Use default fstype if not specified
        if _, result := r.Options["fstype"]; result == false {
+               if r.Options == nil {
+                       r.Options = make(map[string]string)
+               }
                r.Options["fstype"] = fs.FstypeDefault
        }

@govint
Copy link
Contributor

govint commented Dec 24, 2016 via email

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

3 participants