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!

开始愉快的玩耍吧!

相关推荐
LuiChun24 分钟前
与精神病患者的日常探讨20260913
docker
闲云野鹤在人间27 分钟前
Docker入门|第1章 容器生态系统完整解析
运维·服务器·docker·容器·centos
颜颜yan_2 小时前
Eclipse Theia 鸿蒙 PC 适配全记录:在 HarmonyOS PC 上运行完整 IDE 工作台
ide·eclipse·harmonyos
KIDULT°2 小时前
Docker 从 0 入门|吃透容器生态、架构与 Dockerfile 实战
docker·容器·架构
lbb 小魔仙2 小时前
Jupyter Notebook / Lab 深度配置指南:插件 + 内核 + 远程访问 + 容器化部署
ide·python·jupyter
颜颜yan_3 小时前
Geany 鸿蒙 PC 适配全记录:以 Qt 重建轻量 IDE,打通编辑、项目检索与命令执行
ide·qt·harmonyos
重生之小比特3 小时前
【Java SE】类和对象(一)
java·ide·intellij-idea
皓月盈江3 小时前
Linux系统使用VSCode搭建GO开发环境
linux·vscode·ubuntu·golang·debian
putItInYourHand3 小时前
Docker Compose 部署 Mosquitto MQTT Broker 完整实战指南
运维·docker·容器
学习智者3 小时前
《玄》IDE v3.8.2重磅发布:数据外置+全链路优化
开发语言·c++·ide·中文语言 玄