DeepLearning+Docker+SSH

Docker配置

下载docker image

docker pull ufoym/deepo:all-jupyter-py36-cu113
docker pull 

共享权限。如果出现user declined directory sharing问题,打开 Docker DeskTop,将共享文件夹路径添加进来即可。如图:


image.png

创建container

docker run -it -p 8022:22 --ipc=host --name="py36" -v /E/deeplearning:/root/deeplearning ufoym/deepo:all-jupyter-py36-cu113 /bin/bash

进入docker

docker exec -it py36 /bin/bash

换源

cp /etc/apt/sources.list /etc/apt/sources.list.bk
cat < /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
EOF
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
# 默认源
pip config unset global.index-url

SSH配置

安装 openssh-server

apt update
apt install -y vim openssh-server

简单配置

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bk
mkdir /var/run/sshd
echo 'root:123' | chpasswd 
sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
echo "export VISIBLE=now" >> /etc/profile

SSH权限

vim /etc/ssh/sshd_config
PermitRootLogin yes #将PermitRootLogin的值改为yes(去掉前面的#号)

重启激活SSH配置

docker exec -it tf1 /bin/bash
service ssh restart

连接到远程docker

ssh [email protected] -p 8020

提交副本

docker commit -m "py36-ssh" eb16c6ffdb2b torch:py36_ssh

其中,-m 来指定提交的说明信息,跟我们使用的版本控制工具一样;-a 可以指定更新的用户信息;之后是用来创建镜像的容器的ID;最后指定目标镜像的仓库名和 tag 信息。创建成功后会返回这个镜像的 ID 信息。

你可能感兴趣的:(DeepLearning+Docker+SSH)