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容器,点击右侧的->符号,即可进入容器

等待在容器中安装插件

安装完成后即可进入容器

相关推荐
分布式存储与RustFS2 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
玉&心2 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing2 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
guo_wen_qiang2 天前
上传本地镜像到harbor中
docker·容器·持续部署
羑悻的小杀马特2 天前
Dockerfile 全景指南:从入门编写dockerfile到生产环境镜像优化实战,一步步带你从啃透制作指令到镜像制作落地!
docker·dockerfile·镜像制作
BianHuanShiZhe2 天前
docker常见命令
docker
正经教主2 天前
【FDE系列】阶段2:Day 43:Docker Compose — 多容器一键编排
人工智能·docker·fde
忆~遂愿2 天前
本地片库怎么在外面打开?Plex + cpolar 搭一套可远程访问的私人影音库
docker·容器
2501_915909062 天前
移动端开发工具链怎么组合比较好,iOS、Android、跨端三套配置方案
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
Zhu7582 天前
docker环境,vLLM 部署 Qwen3.8-27B
docker·qwen·vllm