vscode + docker + python

1,docker run的时候要加上port

docker run -it --gpus=all -p 2222:22 -v /挂载目录/:/docker 目录1/ -v /挂载目录/:/docker 目录2/ --name=xxx image:v2 /bin/bash

2,docker 内部要安装ssh

2.1方法命令:

apt-get update

apt-get install openssh-server

安装过程中不报错,没有Error,或者在/etc/ssh目录下有sshd_config配置文件就说明安装成功了,最好检查一下配置文件有没有存在。

2.2.修改配置文件

命令:

vim /etc/ssh/sshd_config

保证 PermitRootLogin prohibit-password 这一行被注释,并添加一行 PermitRootLogin yes

2.3.设置root密码,这个密码用于VScode登录使用

命令:passwd

按照提示输入两次即可

2.4.重启ssh服务

service ssh restart(可用命令 service ssh status 查看状态)

3,vscode 安装插件remote-ssh

安装完成后需要reload一下,然后按ctr+shift+p,打开查找栏,输入remote-ssh,选择open Configuration file

4,然后按ctr+shift+p,打开查找栏,输入remote-ssh,选择connect to host,输入 ssh root@ip -p 2222

5,或用vscode左侧栏里的连接docker,

6,Containers Docker version 17.12.0 or later required.

把之前的目录删了都删了。

7,VSCode get "Could not establish connection to "SERVER": Downloading VS Code Server failed - please install either curl or wget on the remote."

连上服务器之后

cd ~

ll

rm -rf .vscode-server

删除远端的vscode服务器。

然后输入wget或者curl检查有无安装这两个工具。

如果提示

Command 'wget' not found, but can be installed with:

apt install wget

说明没有wget或者出于各种原因无法使用这个指令。

尝试进行安装

sudo apt-get install wget

sudo apt-get install curl

如果再次测试还没有用,尝试先卸载再安装

sudo apt-get remove wget

sudo apt-get install wget

sudo apt-get remove curl

sudo apt-get install curl

8,安装python插件

9,配置python编译器,选择docker里conda中的python编译器,OK!

开始愉快的玩耍吧!

相关推荐
无限进步_3 分钟前
【C++】字符串中的字母反转算法详解
开发语言·c++·ide·git·算法·github·visual studio
万象.6 分钟前
docker虚拟化,容器化的原理与实现
运维·docker·容器
挂科边缘11 分钟前
字节跳动 AI 原生 IDE Trae 安装与上手图文教程
ide·人工智能·trae
蓝天星空16 分钟前
docker部署 asp.net程序
docker·容器·asp.net
~莫子25 分钟前
Docker镜像构建
运维·docker·容器
吹牛不交税1 小时前
vue3项目部署到阿里云Alibaba Cloud Linux3系统的docker
docker·容器·.netcore
理性的曜10 小时前
VoloData——基于LangChain的智能数据分析系统
人工智能·vscode·数据分析·npm·reactjs·fastapi·ai应用
火车叼位11 小时前
Docker Compose 网络原理与实战:同一 Compose 服务间如何稳定通信
运维·docker·容器
肖恭伟11 小时前
VScode入门学习
ide·vscode·学习
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ13 小时前
ubuntu 安装部署docker教程
linux·ubuntu·docker