Docker Community Forums

Share and learn in the Docker community.

Mounting folders outside the user's folder on Windows

I may just be failing to searching these forums, as I feel like this is something that would have been asked and answered, but how can I mount folders outside the User directory on Docker Toolbox on WIndows 10 Home? I’ve shared the folder onto the VM, but can’t seem to actually get it to mount into a container (using docker compose). I’ve tried looking online but everything seems to be 2+ years ago and out of date.

I’ve followed the steps here: https://docs.docker.com/toolbox/toolbox_install_windows/#optional-add-shared-directories but when I use docker exec -it dockernginxphpexample_web_1 /bin/ash to try checking out the folder in the container, the directory is empty.

Can I do this? It’s really frustrating that it looks like I’d have to do work in one folder and then move it to another to actually put into my containers.

1 Like

Did you mount a folder into the container? See https://docs.docker.com/engine/reference/run/#volume-shared-filesystems. And if it still doesn’t work check your firewall, it may block the Docker network.

If it helps, this is my docker compose:

version: '3'

services:

  web:
    build:
      context: .
      dockerfile: docker/nginx/Dockerfile
    ports:
      - 8080:80
    volumes:
      - ./public:/code
    links:
      - php

  php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    volumes:
      - ./public:/code

For Windows 10, it is probably better to use Docker for Windows for better integration and more native experience.

On the other hand, for anybody stuck with Docker Toolbox (using iOS or older Windows), one must either:

  1. Create VM with docker-machine --virtualbox-share-folder option, or
  2. Change VM shared folder with Virtualbox UI or VBoxManager

Default Docker Toolbox enables shared folder C:\Users/c/Users, giving users a false sense of capability of accessing any folder on native machine, while it’s actually, well, just a normal Virtualbox shared folder. It’s completely incapable of accessing anywhere beyond C:\Users under default setting.

Therefore, to access other locations, say D:\Myproject\prj1, the procedure would be:

  1. 1 Create virtualbox shared folder D:\Myproject/foo (any mount point is fine)
  2. 2 In docker-compose.yml, specify something like:
    web:
      volumes:
        - /foo/prj1:/code