vscode 进入docker容器

因为我是在windows是安装的vscode,而docker安装在ubuntu上,因此要先使用vscode使用ssh打开远程,再在远程vscode上进入docker容器

1.通过ssh打开远程linux

参考链接vscode 使用ssh打开远程项目

2.安装插件

使用vscode进入ubuntu后,再安装插件,而不是直接在windows上安装插件

Name: Dev Containers

Id: ms-vscode-remote.remote-containers

Description: Open any folder or repository inside a Docker container and take advantage of Visual Studio Code's full feature set.

Version: 0.466.0

Publisher: Microsoft

VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

3.使用Dev Containers插件进入docker容器

1.确保docker容器正常运行

例如本次我运行了一个nginx容器

bash 复制代码
docker pull ubuntu:22.04 
docker run -d --name ubuntu-test --user root ubuntu:22.04 tail -f /dev/null

tail -f /dev/null

让容器保持运行,不退出。

tail -f /dev/null 的意思是持续监听空文件,命令不会结束,因此容器会一直活着。

2.打开

打开Remote Explorer,找到REMOTES下的Dev Containers,找到ubuntu-test容器,点击右侧的->符号,即可进入容器

等待在容器中安装插件

安装完成后即可进入容器

相关推荐
郝学胜-神的一滴4 小时前
Effective Python 条款44:善用属性注解
开发语言·c++·vscode·python·算法·stl
`Levie1 天前
Docker-安装部署、容器管理(一)
docker·容器·eureka
Diligently_1 天前
第 08 篇|单机部署:本地安装与 Docker 最佳实践
运维·spring boot·docker
FungLeo2 天前
FengCMS·PHP+MySQL 升级实录 ·本地容器环境设计:只读挂载、LOCAL_UID、数据卷权限
开发语言·mysql·docker·php·fengcms
cpolar技术支持3 天前
用一份 YAML 画出家里的网络拓扑:哪个口通公网、哪几个容器藏在内网,一张图摊开,再用 cpolar 在外网随时翻这份图
docker·网络拓扑·内网穿透·cpolar·yaml
FriendshipT3 天前
YOLOE Docker 部署实战:三模式推理、掩码输出与跨图视觉的完整实现
运维·人工智能·python·深度学习·docker·容器
the局外人3 天前
Docker 部署:从镜像构建到容器上线
后端·docker·容器
方便面不加香菜4 天前
Docker Compose 文件 -- docker-compose.yml
spring cloud·docker·容器
lambo mercy4 天前
04Docker_Container_容器
docker
Wellijohn5 天前
Docker 瘦身、手写 MCP、异步并发:被问得最多的 12 个问题,一次答完
python·docker·mcp