1、docker容器启动指令
sudo nvidia-docker run -it -p 5555:8888 -v /home/lm:/home/lm --name=yolov4 --shm-size='8G' 920162d78e34 /bin/bash
-it表示交互式运行容器;
–name指定容器名;
–shm-size设置的是共享内存大小,根据需要设置,如果不设置的话,默认64M,训练深度学习模型的时候dataloader会报错提示共享内存不足;
-p是端口映射(主机端口:容器端口),-v是地址映射(主机文件夹:容器文件夹,注意必须用绝对路径);
920162d78e34: 镜像ID
2、容器类ssh服务设置
(base) yjhdl@yjhdl-PowerEdge-R740:~$ docker restart "容器名字/ID"
(base) yjhdl@yjhdl-PowerEdge-R740:~$ docker exec -it "容器名字/ID" /bin/bash #进入容器
#进入到容器 开始一波install 后面远程连接要用
root@e0e19431d0e5:~# apt-get update
root@e0e19431d0e5:~# apt-get install openssh-server
root@e0e19431d0e5:~# apt-get install openssh-client
root@e0e19431d0e5:~# apt-get install ssh
root@e0e19431d0e5:~# apt-get install vim
root@e0e19431d0e5:~# passwd #创建远程服务密码, 后续远程服务需要使用
root@e0e19431d0e5:~# vim /etc/ssh/sshd_config #修改ssh连接的设置
# 在sshd_config 中加入一下代码, 注意单词拼写
PermitRootLogin yes
port=8888 #启动容器时给定的 -p 5555:8888
PubkeyAuthentication yes
PasswordAuthentication yes
3、容器中重启ssh服务
root@e0e19431d0e5:~# service ssh restart # 重启ssh服务
* Restarting OpenBSD Secure Shell server sshd [ OK ]
4、测试ssh是否配置成功
windows系统: 使用cmd终端,输入ssh -p 5555 root@192.168.x.xx
Ubuntu系统: 命令行: ssh -p 5555 root@192.168.x.xx
(base) shawn@shawn-System-Product-Name:~$ ssh -p 8888 root@192.168.x.xx
root@192.168.x.xx's password:
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.4.0-210-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
Last login: Wed Nov 2 14:54:16 2022 from 172.xx.xx.xxx
root@e0e19431d0e5:~#