Last active
August 29, 2015 14:00
-
-
Save vbatts/ace92d1531415c99d554 to your computer and use it in GitHub Desktop.
docker failure on assuming a volume is directory by default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vbatts@jellyroll ~ (master *) $ sudo /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev -d -g /home/docker -D 2>&1 | grep SUCH | |
[debug] volumes.go:182 SUCH VOLUMES: map[] | |
[debug] volumes.go:183 SUCH BIND: map["/repro.sh":{"/home/vbatts/sandbox/reproduction/20140501-rootVolPath/repro.sh" "/repro.sh" "ro"}] | |
[debug] volumes.go:215 SUCH SRC DIRECTORY: %!q(bool=false) | |
[debug] volumes.go:288 SUCH CREATE: "/home/docker/devicemapper/mnt/51f485a015ef5882875e5c9801d6a2b85a51ea590577fbcf5d28f7263a81942d/rootfs/repro.sh", %!q(bool=false) | |
[debug] volumes.go:182 SUCH VOLUMES: map[] | |
[debug] volumes.go:183 SUCH BIND: map[] | |
[debug] volumes.go:215 SUCH SRC DIRECTORY: %!q(bool=true) | |
[debug] volumes.go:288 SUCH CREATE: "/home/docker/devicemapper/mnt/96cced7026d92dd57b7067e2a49400f118b1e4fbbc93a868a1792f63e9024633/rootfs/repro.sh", %!q(bool=true) | |
[debug] volumes.go:251 SUCH FART: "/home/docker/devicemapper/mnt/96cced7026d92dd57b7067e2a49400f118b1e4fbbc93a868a1792f63e9024633/rootfs/repro.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ DOCKER=$D sh repro.sh | |
+ DOCKER=/home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev | |
++ basename repro.sh | |
+ BASENAME=repro.sh | |
+ TAGNAME=farts | |
++ pwd | |
+ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev run -it -v /home/vbatts/sandbox/reproduction/20140501-rootVolPath/repro.sh:/repro.sh:ro busybox ls -l repro.sh | |
-rw-r--r-- 1 default default 444 May 2 16:41 repro.sh | |
+ tar tv | |
+ grep repro.sh | |
++ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev ps -l -q | |
+ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev export 0a85af5efaf0 | |
-rwxr-xr-x 0/0 0 2014-05-02 12:42 repro.sh | |
+ grep -A 2 -w Volumes | |
++ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev ps -l -q | |
+ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev inspect 0a85af5efaf0 | |
"Volumes": { | |
"/repro.sh": {} | |
}, | |
-- | |
"Volumes": { | |
"/repro.sh": "/home/vbatts/sandbox/reproduction/20140501-rootVolPath/repro.sh" | |
}, | |
++ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev ps -l -q | |
+ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev commit 0a85af5efaf0 farts | |
111c1797767b5fd62dca8e5931b2c1f6e9c47683954a7ca2846ae3441c0d636d | |
+ grep -A 2 -w Volumes | |
+ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev inspect farts | |
"Volumes": { | |
"/repro.sh": {} | |
}, | |
-- | |
"Volumes": { | |
"/repro.sh": {} | |
}, | |
+ /home/vbatts/src/docker/docker/bundles/0.10.0-dev/dynbinary/docker-0.10.0-dev run farts ls -l repro.sh | |
2014/05/02 12:42:03 Error: Cannot start container 4f3c8ead2241ec312e12d27a3a9a4fac36fd87748ba4b986c0073ebf8b5b8f47: readdirent: not a directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -x | |
DOCKER=${DOCKER:-docker} | |
BASENAME=$(basename $0) | |
TAGNAME=${TAGNAME:-farts} | |
${DOCKER} run -it -v $(pwd)/$0:/${BASENAME}:ro busybox ls -l ${BASENAME} | |
${DOCKER} export $(${DOCKER} ps -l -q) | tar tv | grep ${BASENAME} | |
${DOCKER} inspect $(${DOCKER} ps -l -q) | grep -A 2 -w Volumes | |
${DOCKER} commit $(${DOCKER} ps -l -q) ${TAGNAME} | |
${DOCKER} inspect ${TAGNAME} | grep -A 2 -w Volumes | |
${DOCKER} run ${TAGNAME} ls -l ${BASENAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/daemon/volumes.go b/daemon/volumes.go | |
index a657084..c100420 100644 | |
--- a/daemon/volumes.go | |
+++ b/daemon/volumes.go | |
@@ -179,6 +179,8 @@ func createVolumes(container *Container) error { | |
var srcPath string | |
var isBindMount bool | |
srcRW := false | |
+ utils.Debugf("SUCH VOLUMES: %q", container.Volumes) | |
+ utils.Debugf("SUCH BIND: %q", binds) | |
// If an external bind is defined for this volume, use that as a source | |
if bindMap, exists := binds[volPath]; exists { | |
isBindMount = true | |
@@ -189,11 +191,6 @@ func createVolumes(container *Container) error { | |
if strings.ToLower(bindMap.Mode) == "rw" { | |
srcRW = true | |
} | |
- if stat, err := os.Stat(bindMap.SrcPath); err != nil { | |
- return err | |
- } else { | |
- volIsDir = stat.IsDir() | |
- } | |
// Otherwise create an directory in $ROOT/volumes/ and use that | |
} else { | |
@@ -210,6 +207,12 @@ func createVolumes(container *Container) error { | |
} | |
srcRW = true // RW by default | |
} | |
+ if stat, err := os.Stat(srcPath); err != nil { | |
+ return err | |
+ } else { | |
+ volIsDir = stat.IsDir() | |
+ } | |
+ utils.Debugf("SUCH SRC DIRECTORY: %q", volIsDir) | |
if p, err := filepath.EvalSymlinks(srcPath); err != nil { | |
return err | |
@@ -245,6 +248,7 @@ func createVolumes(container *Container) error { | |
if srcRW && !isBindMount { | |
volList, err := ioutil.ReadDir(rootVolPath) | |
if err != nil { | |
+ utils.Debugf("SUCH FART: %q", rootVolPath) | |
return err | |
} | |
if len(volList) > 0 { | |
@@ -281,6 +285,7 @@ func createVolumes(container *Container) error { | |
} | |
func createIfNotExists(path string, isDir bool) error { | |
+ utils.Debugf("SUCH CREATE: %q, %q", path, isDir) | |
if _, err := os.Stat(path); err != nil { | |
if os.IsNotExist(err) { | |
if isDir { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment