How to use vscode remote containers with Docker To

2020-07-30 00:50发布

问题:

I use Windows 7 and can't install Docker for Windows, so I use Docker Toolbox.

Docker Toolbox is not supported by Microsoft Visual Studio Code for Remote Container Development.

But I need to use this functionality with my docker toolbox.

There is an issue on Github not solved yet https://github.com/microsoft/vscode-remote-release/issues/95

回答1:

You need to start your docker-machine (tested with vscode 1.40.2+)

In your .devcontainer.json you can overwrite the workspace mount volume command (More info here)

"workspaceMount": "src=//c/Users/yourusername/git/reponame,dst=/workspaces/reponame,type=bind,consistency=delegated"

VSCode search the default workspace inside the container in /workspaces with the same name as the original and opens it automatilly, but you can override this in .devconatiner if you need or open it manually.

Important: your repository should always be inside your windows user profile (%userprofile%). This is a requirement from Docker Toolbox.

Note: the problem with Docker Toolboox is that Visual Studio Code doesn't support the docker-machine path style to mount volumes by default. But this workaround can help you.

Updated 2020/05/13

Tested with 1.44 it still works but you can't use an environment variable to config mount paths yet. So each developer should customize the local path of the repo after clone the repository.