How do I mount a Docker volume while using a Windows host?
<p>Mounting a Docker volume while being under a Windows host, has been a huge pain for me, and I could not get it to work.</p>

<p>Currently I got the following simple Dockerfile:</p>

<pre><code>FROM php:5-apache
RUN apt-get update
</code></pre>

<p>When I build an image from it, and start a container</p>

<pre><code>docker build -t phisch:dev .
docker run phisch:dev
</code></pre>

<p>the container starts properly.</p>

<p>But when I am trying to mount a volume,</p>

<pre><code>docker run -v /c/Users/phisch/dev/htdocs:/var/www phisch:dev
</code></pre>

<p>the following message will be displayed:</p>

<pre><code>C:\Users\phisch\dev&gt;docker run -v /c/Users/phisch/dev/htdocs:/var/www phisch:dev
no such file or directory
docker: Error response from daemon: Container command not found or does not exist..
</code></pre>

<p>The <code>/var/www</code> directory definitely exists in the container, and trying other directories does not change the result. Prepending a trailing slash to the host-side directory does not help either. (<code>//c/Users/phisch/dev/htdocs</code>)</p>

<p>How do I mount for example <code>/var/www</code> to <code>C:/Users/phisch/dev/htdocs</code>?</p>

<pre><code>phisch@DESKTOP-UC1LB9J MINGW64 ~/dev (master)
$ docker inspect phisch:dev
[
    {
        "Id": "sha256:73c1533222a905a378f12505ccbd9e9b34cde5a4b34ed008c39e23d5d58a9c91",
        "RepoTags": [
            "dev_web:latest",
            "phisch:dev",
            "phisch:dev3"
        ],
        "RepoDigests": [],
        "Parent": "sha256:d2c4149d86c4dfceaff0e9c4eb5a5d42ca7815f81dd08baad4dc8bda6db2fb10",
        "Comment": "",
        "Created": "2016-02-10T12:16:37.667236134Z",
        "Container": "dad811f51ef3b94d9845d13a0e43ad07ccd5684ea2747b3846accdc71abeb628",
        "ContainerConfig": {
            "Hostname": "e06f5a03fe1f",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHP_INI_DIR=/usr/local/etc/php",
                "PHP_EXTRA_BUILD_DEPS=apache2-dev",
                "PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2",
                "GPG_KEYS=0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3",
                "PHP_VERSION=5.6.18",
                "PHP_FILENAME=php-5.6.18.tar.xz",
                "PHP_SHA256=54dd9106c3469bc7028644d72ac140af00655420bbaaf4a742a64e9ed02ec1b0"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "apt-get update"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:d2c4149d86c4dfceaff0e9c4eb5a5d42ca7815f81dd08baad4dc8bda6db2fb10",
            "Volumes": null,
            "WorkingDir": "/var/www/html",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "1.10.0",
        "Author": "",
        "Config": {
            "Hostname": "e06f5a03fe1f",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHP_INI_DIR=/usr/local/etc/php",
                "PHP_EXTRA_BUILD_DEPS=apache2-dev",
                "PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2",
                "GPG_KEYS=0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3",
                "PHP_VERSION=5.6.18",
                "PHP_FILENAME=php-5.6.18.tar.xz",
                "PHP_SHA256=54dd9106c3469bc7028644d72ac140af00655420bbaaf4a742a64e9ed02ec1b0"
            ],
            "Cmd": [
                "apache2-foreground"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:d2c4149d86c4dfceaff0e9c4eb5a5d42ca7815f81dd08baad4dc8bda6db2fb10",
            "Volumes": null,
            "WorkingDir": "/var/www/html",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 491287784,
        "VirtualSize": 491287784,
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        }
    }
]
</code></pre>

<p><strong>It turns out the container-side directory <code>/var/www</code> needs to be empty, since it had a sub-directory <code>www</code>. Docker was not able to use it as a mounting point.</strong></p>