Skip to content

[WSL2] bind mount (--mount) with a directory does not exist does not generate errors #10422

@sarisia

Description

@sarisia
  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: 00EF965D-AD0F-462B-B261-776161C213A0/20210219042536

Actual behavior

With WSL Integration, bind mounting the directory that does not exist in the host
does not generate errors and automatically creates the directory instead.

[sarisia@Marine test]$ docker run --mount "type=bind,src=$(pwd)/bindtest,dst=/bindtest" --name bindtest -d nginx
ab2d73dda77767915206486ec9953ab520a6ca34e3a1eba238d1d1f50d2887a3
[sarisia@Marine test]$ ls -al
total 12
drwxr-xr-x 3 sarisia sarisia 4096 Feb 19 13:20 .
drwxr-xr-x 7 sarisia sarisia 4096 Feb 19 13:20 ..
drwxr-xr-x 2 root    root    4096 Feb 19 13:20 bindtest

Expected behavior

docker run should generate errors, as described in the docs

Tested the same command with the Ubuntu VM (VMWare Workstation Player):

sarisia@ubuntu:~/run$ sudo docker run --mount "type=bind,src=$(pwd)/bindtest,dst=/bindtest" --name bindtest -d nginx
docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/sarisia/run/bindtest.
See 'docker run --help'.
`docker version` in Ubuntu VM
sarisia@ubuntu:~/run$ sudo docker version
Client: Docker Engine - Community
 Version:           20.10.3
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        48d30b5
 Built:             Fri Jan 29 14:33:21 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.3
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       46229ca
  Built:            Fri Jan 29 14:31:32 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Information

  • Windows Version:
Edition	Windows 10 Education
Version	20H2
Installed on	‎11/‎2/‎2020
OS build	19042.804
Experience	Windows Feature Experience Pack 120.2212.551.0
  • Docker Desktop Version: 3.1.0 (51484)
  • WSL2 or Hyper-V backend?: WSL2
  • Are you running inside a virtualized Windows e.g. on a cloud server or a VM: No

docker version in WSL2:

[sarisia@Marine test]$ docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.7
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:17:34 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:15:28 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Steps to reproduce the behavior

  1. make sure you have no bindtest directory in the host:
[sarisia@Marine test]$ ls -al
total 8
drwxr-xr-x 2 sarisia sarisia 4096 Feb 19 13:37 .
drwxr-xr-x 7 sarisia sarisia 4096 Feb 19 13:20 ..
  1. run the container with bind mount:
[sarisia@Marine test]$ docker run --mount "type=bind,src=$(pwd)/bindtest,dst=/bindtest" --name bindtest -d nginx
ab2d73dda77767915206486ec9953ab520a6ca34e3a1eba238d1d1f50d2887a3
  1. step 2 should be error, but it's not. Instead, bindtest directory is created.
[sarisia@Marine test]$ ls -al
total 12
drwxr-xr-x 3 sarisia sarisia 4096 Feb 19 13:20 .
drwxr-xr-x 7 sarisia sarisia 4096 Feb 19 13:20 ..
drwxr-xr-x 2 root    root    4096 Feb 19 13:20 bindtest

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions