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

Mounting file that was previously non-existent fails with: [8] System error: not a directory #19304

Closed
goneflyin opened this issue Jan 13, 2016 · 1 comment

Comments

@goneflyin
Copy link

To preface, this issue may be specific to boot2docker and/or VirtualBox.

version details:

bash-3.2$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.5.1
 Git commit:   a34a1d5
 Built:        Sat Nov 21 00:48:57 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

bash-3.2$ docker info
Containers: 25
Images: 355
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 405
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b - Fri Nov 20 19:33:59 UTC 2015
CPUs: 2
Total Memory: 7.79 GiB
Name: ndev
ID: 7FPV:3H7E:T5XH:4DOS:DJ3O:D4SA:F7FR:7RHG:2LYQ:JZ2I:XXB5:JR3M
Debug mode (server): true
 File Descriptors: 150
 Goroutines: 349
 System Time: 2016-01-13T15:51:46.916222527Z
 EventsListeners: 2
 Init SHA1:
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=virtualbox

Also, running OS X v10.10 with VirtualBox:

bash-3.2$ VBoxManage -v
5.0.12r104815

bash-3.2$ uname -a
Darwin <elided>.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep  1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64

Because boot2docker automounts /Users, this reproduction must be done in your home directory or at a lower level.

  1. Mount a plain image (I used ubuntu) and mount a non-existent file when running the image. Note that in the local filesystem a nested directory was created when an existent file or directory could not be found.
  2. Subsequently, delete the auto-created innermost directory and replace it with a normal file.
  3. Re-run your docker image with the same volume mounting info.
bash-3.2$ pwd
/Users/scott/docker-issue

bash-3.2$ ls -al
total 0
drwxr-xr-x    2 scott  wheel    68 Jan 13 10:16 .
drwxr-xr-x+ 138 scott  staff  4692 Jan 13 10:05 ..

bash-3.2$ docker run --rm -i -t -v $(pwd)/a/nested/file.out:/file.out ubuntu /bin/bash

root@e6e3ac91631c:/# ls -al file.out
total 4
drwxr-xr-x  1 1000 staff   68 Jan 13  2016 .
drwxr-xr-x 33 root root  4096 Jan 13 16:00 ..

root@e6e3ac91631c:/# exit

bash-3.2$ ls -al
total 0
drwxr-xr-x    3 scott  wheel   102 Jan 13 10:16 .
drwxr-xr-x+ 138 scott  staff  4692 Jan 13 10:05 ..
drwxr-xr-x    3 scott  wheel   102 Jan 13 10:16 a

bash-3.2$ ls -al a/nested
total 0
drwxr-xr-x  3 scott  wheel  102 Jan 13 10:16 .
drwxr-xr-x  3 scott  wheel  102 Jan 13 10:16 ..
drwxr-xr-x  2 scott  wheel   68 Jan 13 10:16 file.out

bash-3.2$ ls -al a/nested/file.out
total 0
drwxr-xr-x  2 scott  wheel   68 Jan 13 10:16 .
drwxr-xr-x  3 scott  wheel  102 Jan 13 10:16 ..

bash-3.2$ rmdir a/nested/file.out

bash-3.2$ echo "now this is a file" > a/nested/file.out

bash-3.2$ docker run --rm -i -t -v $(pwd)/a/nested/file.out:/file.out ubuntu /bin/bash
Timestamp: 2016-01-13 16:00:53.095601395 +0000 UTC
Code: System error

Message: not a directory

Frames:

---
0: setupRootfs
Package: github.com/opencontainers/runc/libcontainer
File: rootfs_linux.go@40

---
1: Init
Package: github.com/opencontainers/runc/libcontainer.(*linuxStandardInit)
File: standard_init_linux.go@57

---
2: StartInitialization
Package: github.com/opencontainers/runc/libcontainer.(*LinuxFactory)
File: factory_linux.go@242

---
3: initializer
Package: github.com/docker/docker/daemon/execdriver/native
File: init.go@35

---
4: Init
Package: github.com/docker/docker/pkg/reexec
File: reexec.go@26

---
5: main
Package: main
File: docker.go@18

---
6: main
Package: runtime
File: proc.go@63

---
7: goexit
Package: runtime
File: asm_amd64.s@2232
Error response from daemon: Cannot start container 12112c4bab1d924a10ebe1e46ea1446cf6f1131d7595287681b624a047237c18: [8] System error: not a directory

bash-3.2$
@cpuguy83
Copy link
Member

This is because when the file doesn't exist, docker creates a dir (note that this functionality is deprecated and will be removed in 1.11). If in the container there exists a file at the path you specified, you'll get the error since you can't mount a dir onto a file.

For example: -v /foo:/bar.
If /foo doesn't exist docker creates a dir called /foo
If /bar does exist, and /bar is a file, this will cause a conflict when trying to mount the new /foo dir onto the file /bar in the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants