PyCharm连接Docker中的容器(ubuntu)

一、为什么要用Pycharm链接Docker中的ubuntu

因为在进行深度学习的时候,基于windows系统在开发的过程中,老是出现很多问题,大多数是环境问题。

尽管安装了Conda,也不能很好的解决问题,使用ubuntu是最好的选择。

二、需要有一个运行了ubuntu的容器

进入这个容器

复制代码
docker exec -it ubuntu22 /bin/bash

进行一下系统升级,并且安装openssh-server

复制代码
apt update
apt install -y openssh-server

启动SSH服务

复制代码
service ssh start

三、开放ubuntu的远程连接

1.设置root密码

复制代码
root@2a1584c779af:/# passwd root
New password:
Retype new password:
passwd: password updated successfully
root@2a1584c779af:/#

2.安装VIM

复制代码
apt install vim

3.编辑配置文件

复制代码
vim /etc/ssh/sshd_config

#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
PasswordAuthentication yes
PubkeyAuthentication yes

4.重启服务

复制代码
root@2a1584c779af:/# service ssh restart
 * Restarting OpenBSD Secure Shell server sshd                                                                   [ OK ]
root@2a1584c779af:/#

四、PyCharm进行连接

1.这样就属于连接成功了。

五、可能在远程连接的时候会报下面的错误

复制代码
env: '/usr/bin/which: this version of `which\' is deprecated; use `command -v\' in scripts instead.'

需要修改/usr/bin/which脚本文件,将echo >&2 "$0: this version of \`which' is deprecated; use \`command -v' in scripts instead."注释掉。

测试,运行成功。

相关推荐
MicrosoftCloud7 小时前
用户权限 04|/etc/sudoers 安全配置:从最小授权到「别把 ALL 随便给人」
运维·安全·ubuntu·sudo·sudoers
梦想不只是梦与想7 小时前
docker-compose.yml
docker·docker-compose·docker run
YCOSA20259 小时前
Windows11_InsiderPreview_EnterpriseVL_x64_zh-cn_29680_1000.iso 官方直链
windows
怎么没有名字注册了啊11 小时前
Windows Server 2008 R2 如何开启Aero
windows
lingchen190612 小时前
Windows CMD 的 `cd`(change directory,切换目录)命令
windows·命令模式
ITHAOGE1514 小时前
下载 | Win11 26H2 正式版发布!(ISO映像、2026年度版本、26300.9457、Windows 11)
windows·科技·微软·电脑
YCOSA202515 小时前
雨晨 Windows 11 IoT 企业版 Edge 轻装 VCDX 29680.1000
windows·物联网
笨笨努力中16 小时前
2002年Windows XP系统下载视频资源迁移云盘
windows
更深兼春远16 小时前
第2篇:Dify 部署保姆级教程:用 Docker跑起来
docker·容器·dify
l1t18 小时前
修复WSL CreateInstance/E_UNEXPECTED和 mounted read-only 错误
linux·windows·wsl