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!

开始愉快的玩耍吧!

相关推荐
AndyHuang19768 分钟前
【避坑指南】Visual Studio 插件报错 “Windows Terminal (wt.exe) was not found in PATH“ 完美解决
ide·windows·visual studio
master33617 分钟前
GitLab (Docker) 常用命令及解决方案清单
docker·容器·gitlab
卧室小白25 分钟前
K8S基础-控制器&deploy&pod回滚更新&service
docker·容器·kubernetes
向上的车轮27 分钟前
Typora插件开发指南:打造专属IDE式写作环境
ide·typora插件
许彰午38 分钟前
零基础无文档啃读纯实操摸索学会Docker全过程
运维·docker·容器
江湖有缘40 分钟前
零门槛搭建个人微社区:Docker部署 Paopao-ce 完整教程
运维·docker·容器
qq_356408661 小时前
GitLab 单机私有化部署文档(基于 Docker 环境)
docker·gitlab
唯刻V1 小时前
你的IDE已经不认识你了
android·ide·android-studio·cli
彷徨而立1 小时前
【Visual Studio】msbuild 使用举例
ide·visual studio
lazy H1 小时前
IDEA 如何配置 JDK?项目 SDK 报错解决方法
java·ide·后端·学习·intellij-idea