Docker Compose volume mounts don't work with Docker Toolbox running on Windows

I’m running Docker Compose 1.9.0 on Windows with Docker Toolbox (VirtualBox) as my host. When I follow the “getting started” steps for Compose (https://docs.docker.com/compose/gettingstarted/), I get an “invalid bind mount spec” error.

C:\Work\composetest>docker-compose up
Creating composetest_redis_1
Creating composetest_web_1

ERROR: for web  Cannot create container for service web: Invalid bind mount spec "C:\\Work\\composetest:/code:rw": Invalid volume specification: 'C:\Work\composetest:/code:rw'
e[31mERRORe[0m: Encountered errors while bringing up the project.

My docker-compose.yml file is exactly as it is in the walk through.

It seems like docker-compose is expanding the relative path in the compose file into an absolute Windows path, which is invalid in the container host environment (which is Linux on VirtualBox).

How is this supposed to work? I understand that VirtualBox has its own volume mounting layer, so I think there are some missing steps in this process (is there a way to get docker-compose to run on the container host within VirtualBox?).


Other attempts:

  • I tried replacing the volume specification in the docker-compose.yml file with an absolute Posix path based on a shared folder mount in VirtualBox, but docker-compose still transforms the path specification into a Windows path by reversing the forward slashes into back slashes, so I get an “invalid characters for a local volume name” error.

  • I tried installing Docker for Windows, but it enables Hyper-V which doesn’t work with Bitlocker on my company laptop. So, I have to use Docker Toolbox.

1 Like

I had the same trouble. I used docker toolbox 1.12.5. After regrade to 1.12.0 problem was resolved. Hope this will help you.

Got this working (finally) for Windows toolbox 12.5.x by adding a shared folder using VirtualBox Manager and disabling path conversion.

Redis example:

  1. Added a shared folder via VirtualBox Manager or command line
    • D:\Projects\MyProoject\db -> /var/db
  2. Set COMPOSE_CONVERT_WINDOWS_PATHS=0
  3. Mapped redis volume as: "/var/db/redis:/data:rw"

Now creates redis database in D:\Projects\MyProoject\db\redis\dump.rdb

If it’s complaining that you’re using invalid characters its probably because you dont have COMPOSE_CONVERT_WINDOWS_PATHS=0.and it’s generating \ chars in the path that are invalid.
Docker Compose likes to add \ chars to your path that you didn’t put there and then blame you for it.

1 Like

Hello
Can you please tell me how you created this shared folder
D:\Projects\MyProoject\db -> /var/db

I am using windows 7 and trying to mount my container’s volume.

Hi,

you need to open VirtualBox Manager, edit the configuration of the “default” VM by adding a new entry in the shared folder section. Then I also needed to reboot the “default” VM by showing it’s console screen and typing reboot.

However, after doing this docker-compose still complained for me that there were invalid characters. I found out that for me the environment variable COMPOSE_CONVERT_WINDOWS_PATHS must be set to 1. Important to know that in Windows Powershell you need to do this by doing exactly so:
$env:COMPOSE_CONVERT_WINDOWS_PATHS=1

After that my docker-compose up finally worked with the shared folder.

1 Like