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."注释掉。

测试,运行成功。

相关推荐
java_logo18 小时前
MySQL Server Docker 容器化部署指南
linux·运维·数据库·docker·容器
猫头虎18 小时前
如何解决 pip install 编译报错 fatal error: hdf5.h: No such file or directory(h5py)问题
人工智能·python·pycharm·开源·beautifulsoup·ai编程·pip
Radan小哥18 小时前
Docker学习笔记—day0010
笔记·学习·docker
e***193518 小时前
docker compose安装redis
redis·docker·容器
課代表18 小时前
Windows 文本搜索命令 findstr
windows·正则表达式·命令行·文本·匹配·搜索·findstr
hadage23318 小时前
--- docker 一些指令的汇总 ---
运维·docker·容器
n***271918 小时前
【MySQL数据库】Ubuntu下的mysql
数据库·mysql·ubuntu
⊙ ∀ ⊙18 小时前
ubuntu打印机配置
ubuntu
好奇的菜鸟18 小时前
WSL 2 安装 Ubuntu 24.04 及系统迁移到非系统盘
linux·运维·ubuntu