Skip to content

Nested bind mounts create empty directory on the host #26051

@jordanlewis

Description

@jordanlewis

Issue Description:
When using bind mounts that are nested on the container side, Docker erroneously creates empty directories that match the nested structure on the host side.

Output of docker version:

Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 4
Server Version: 1.12.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 34
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: host null overlay bridge
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.15-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.954 GiB
Name: moby
ID: X63G:YAIL:6A3B:CAIG:RY7T:YD5J:56WM:OAJ3:MJ27:YSN4:6G5D:ZVJJ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 19
 Goroutines: 30
 System Time: 2016-08-26T01:01:01.833759981Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Username: jordanlewis
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

Additional environment details (AWS, VirtualBox, physical, etc.):
Docker for Mac, OS X El Capitan

Steps to reproduce the issue:

  1. mkdir -p /tmp/foo /tmp/bar
  2. docker run --rm --volume="/tmp/foo:/foo" --volume="/tmp/bar:/foo/bar" ubuntu true
  3. ls -la /tmp/foo

Describe the results you received:
There is an empty directory named bar on the host in /tmp/foo.

Describe the results you expected:
/tmp/foo and /tmp/bar remain empty and untouched on the host.

Additional information you deem important (e.g. issue happens only occasionally):
This happens as well on Linux, but the erroneously created directory is also owned by root.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/runtimeRuntimekind/enhancementEnhancements are not bugs or new features but can improve usability or performance.version/1.12

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions