How can Docker Desktop mount Windows Volumes?

Viewed 63

Let's say you're on Windows and you want to mount a volume like so:

docker run --name nginx -v "C:\\my\\path:/usr/share/nginx/html" -p "8080:80" nginx

This works perfectly with Docker Desktop, which uses WSL2.

However, with a custom Docker in WSL2, you'll get:

docker: Error response from daemon: invalid mode: /usr/share/nginx/html.

There are some questions covering this topic:

Their bottom line is: Use /mnt/c/.... But Docker Desktop doesn't need this. When you inspect a container created by Docker Desktop, you'll even see:

"Mounts": [
    {
        "Type": "bind",
        "Source": "C:\\my\\path",
        "Destination": "/usr/share/nginx/html",
        "Mode": "rw",
        "RW": true,
        "Propagation": "rprivate"
    }
],

How is it possible that Docker Desktop's WLS2 Docker daemon can handle Windows paths?

0 Answers
Related