如何在docker机器(和docker工具箱)中使用vscode远程容器? [英] How to use vscode remote containers with docker machine (and docker toolbox)?

查看:111
本文介绍了如何在docker机器(和docker工具箱)中使用vscode远程容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Windows 7,并且无法为Windows安装Docker,所以我使用Docker Toolbox.

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

用于远程容器开发的Microsoft Visual Studio Code不支持Docker Toolbox.

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

但是我需要在我的docker工具箱中使用此功能.

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

Github上有一个尚未解决的问题 https://github.com/microsoft/vscode-remote-release/issues/95

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

推荐答案

Docker Toolbox是基于docker-machine和virtualbox使用本地VM的产品.该虚拟机默认共享所有用户配置文件,因此您可以使用路径/c/user/< profile_name>/folder/a/b与虚拟机中的容器共享配置文件上的任何文件夹.

Docker Toolbox was a product based on docker-machine and virtualbox to use a local VM. That VM has all your user profile shared by default, so you can share any folder on your profile with a container in the VM using the path /c/user/<profile_name>/folder/a/b.

警告:请小心,避免与不信任的图片共享所有用户个人资料

使用docker计算机时启用VSCode远程容器的步骤

您需要启动docker机器(经过vscode 1.40.2+的测试)

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

在您的.devcontainer.json文件中,您可以覆盖工作空间安装卷命令(更多信息

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

"workspaceMount":" src =//c/Users/您的用户名/git/重命名,dst =/workspaces/重命名,type = bind,consistency =委托"

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

VSCode在/workspaces中以与原始名称相同的名称搜索容器内的默认工作空间并自动将其打开,但是如果需要,可以在.devconatiner中覆盖此默认工作空间,或者手动打开它.

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

重要:您的存储库应始终位于Windows用户个人资料(%userprofile%)中.这是Docker Toolbox默认共享的要求.

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

注意:Docker Toolboox的问题在于,Visual Studio Code不支持默认情况下挂载卷的docker-machine路径样式.但是,这种解决方法可以为您提供帮助.

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.

更新2020/05/13

在1.44下测试仍然可以使用,但是您还不能使用环境变量来配置安装路径.因此,每个开发人员都应在克隆存储库后自定义存储库的本地路径.

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.

更新2020/10/29 微软添加了信息以及如何在Docker Machine中使用VSCode远程容器这里.Microsoft文档让您想象应该使用哪种路径,因为它不假定docker-machine环境是本地VM.在这里您可以找到此答案有用.

Updated 2020/10/29 Microsoft added information and how to use VSCode remote containers with Docker Machine here. Microsoft docs let's you imagine what kind of path should you use because it doesn't assume that the docker-machine environment is a local VM. This is where you can found this answer usefull.

这篇关于如何在docker机器(和docker工具箱)中使用vscode远程容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆