Fix Docker Invalid Mount Path Issues on Windows 10
Tags: docker, dockertoolbox, vscode, windows10
Published: 2020-05-03 16:16:01

---
title: Fix Docker Invalid Mount Path Issues on Windows 10
published: true
description: How to fix the annoying "mount path must be absolute" problem when you're running Docker Toolbox on Windows 10 with Remote Containers in VSCode.
tags: docker, docker_toolbox, vscode, windows10
---

First of all, Niall Maher's article was an awesome introduction to getting up and running with Docker via Remote Containers in VSCode! It made me want to try out Docker for my webdev setup as well. {% link nialljoemaher/dockerize-your-development-environment-1a50 %} 

Once I finished reading the article, I really wanted to test it out on my own. But things didn't work out right out of the box for me... 

The official [VSCode Remote Containers](https://code.visualstudio.com/docs/remote/containers#_installation) documentation leads off with installing `Docker Desktop`. It turns out that my version of Windows (10 Home) is not supported, because it lacks the `Hyper-V` and `Containers Windows` features. (Minimum requirements: Windows 10 Pro/Enterprise). 

So to get things running, I had to install the now *unsupported Docker Toolbox*, thinker with the settings a little bit and enjoy me some Docker containers. If anyone else encounters any folder binding/mounting issues, here is what I had to do...

## Installing Docker Toolbox

Please follow this guide for downloading and installing the [Docker Toolbox](https://docs.docker.com/toolbox/toolbox_install_windows/#step-2-install-docker-toolbox).

Don't forget to verify your installation, like running the Docker Quickstart Terminal!

## Mount Binding Issues on Windows

Mounting the proper host folder and using it inside the Docker dev container was the biggest hurdle in my setup. I'm sure that this works like a charm on Linux and probably MacOS, but there were some issues on Windows...

This is the error that I encountered multiple times during the container building process:

```JS
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: invalid
mount config for type "bind": invalid mount path: 'd:/my-projects/test-docker-project' mount
path must be absolute.
```

There is a lot of information about how to address this issue, but most of it was related to setting `MSYS_NO_PATHCONV=1` environment variable when launching Docker [GitHub Source](https://github.com/docker/toolbox/issues/673#issuecomment-355275054). That was already applied in my environment though and things didn't work out of the box. So I had to find another way to mount my project folder through VirtualBox.

### Add Your Project Folder(s) to VirtualBox

Docker Toolbox works through VirtualBox. A version of VirtualBox comes with your Docker Toolbox installation, so you don't have to worry about that. Once you have things installed, you need to do the following:

- Open *Oracle VM VirtualBox*
- Find and select the VM that was created by Docker (usually called `default`)
- Open the Settings for that Virtual Machine (Gear Icon - Settings)
- Select `Shared Folders`
- Select `Machine Folders`
- Click the `+` sign to add a new folder:
    - `Folder path`: select your project code folder (Example: `d:\my-projects`)
    - `Folder name`: the name of the folder that will appear in your container. (Example: `my-projects`). You'll use this folder name again, so write it down :-)
    - Check `Auto-mount` & `Make Permanent`
    - Click OK.
- Click OK to save the settings. Note: The newly mounted folder should apply without a VM reboot.

### Update VSCode devcontainer.json Options

Now we need to map the newly mounted folder from the VirtualBox VM to a folder inside of our Docker container. To do that, we need to make some changes to our devcontainer.json file:

- **source**: /my-projects/test-docker-project
- **target**: /workspace

This is how that looks in devcontainer.json:

```JSON
{
    "workspaceMount": "source=/my-projects/test-docker-project,target=/workspace,type=bind,consistency=relegated",
    "workspaceFolder": "/workspace",
}
```

After making these changes to your *devcontainer.json* file you'll have to rebuild your container (*Remote-Containers: Rebuild Container OR Remote-Containers: Rebuild and Reopen Folder in Container*).

Now you should be ready to go! 

Let me know if you encountered this or other problems in your Docker setup and how you were able to fix them.