Docker 容器连接 | 菜鸟教程 (runoob.com)
1.为了使pycharm可以通过ssh链接到docker容器,我们需要为docker容器分配端口,分配端口的命令如下:
C:\Windows\system32>docker run --name ubuntu-test -it -p 6767:80 ubuntu:latest
2.怎么在docker中使用nvidia显卡 - 思念殇千寻 - 博客园 (cnblogs.com)
2.1 docker 安装ubuntu
(18条消息) windows环境下docker建立ubuntu实例,mobaxterm连接该实例_动力蜗牛2021的博客-CSDN博客
2.2把容器保存为镜像
(18条消息) Docker:将docker容器保存为docker镜像(打成tar包)_烟雨天青色的博客-CSDN博客_docker 保存新镜像
C:\Windows\system32>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2b9597eaef33 ubuntu:latest "bash" 25 minutes ago Exited (0) 8 seconds ago ubuntu-latest
C:\Windows\system32>docker commit 2b9597eaef33 ubuntu:v1
sha256:76e58fa8995d2e52bc94f4a764672125a2d714cf44141b2431b112677e156913
C:\Windows\system32>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu v1 76e58fa8995d 13 seconds ago 286MB
ubuntu latest ba6acccedd29 12 months ago 72.8MB
3.docker目录映射
#创建映射目录命令
C:\Windows\system32>docker run --name conda-v1 -v C:\Users\WZ\Desktop\conda:/data -it ubuntu:latest
进入目录命令
root@1c0ae099dba0:/# cd /data/
查看目录文件
root@1c0ae099dba0:/data# ll
total 4
drwxrwxrwx 1 root root 0 Oct 14 17:38 ./
drwxr-xr-x 1 root root 4096 Oct 14 17:42 ../
在映射目录 创建文件
root@1c0ae099dba0:/data# mkdir hellow-docker
root@1c0ae099dba0:/data# ll
total 4
drwxrwxrwx 1 root root 0 Oct 14 17:44 ./
drwxr-xr-x 1 root root 4096 Oct 14 17:42 ../
drwxrwxrwx 1 root root 0 Oct 14 17:44 hellow-docker/
4.docker+ubuntu,安装anaconda
将下载的conda 镜像复制到主机目录
root@e3155ddfb4ac:/data# bash Anaconda3-2022.05-linux-x86_64.sh
(17条消息) Ubuntu系统anaconda安装初始化和env环境切换_柏常青的博客-CSDN博客_anaconda 初始化
5.进入conda环境
#命令
root@c07d5cb47355:/# source ~/anaconda3/bin/activate
#结果
(base) root@c07d5cb47355:/#
6.也许的地址
(base) root@c07d5cb47355:/# anaconda-navigator
Traceback (most recent call last):
File "/root/anaconda3/bin/anaconda-navigator", line 7, in <module>
from anaconda_navigator.app.main import main
File "/root/anaconda3/lib/python3.9/site-packages/anaconda_navigator/app/main.py", line 19, in <module>
from anaconda_navigator.app.start import start_app
File "/root/anaconda3/lib/python3.9/site-packages/anaconda_navigator/app/start.py", line 17, in <module>
from qtpy.QtGui import QIcon
File "/root/anaconda3/lib/python3.9/site-packages/qtpy/QtGui.py", line 30, in <module>
from PyQt5.QtGui import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
7.查看 conda的虚拟环境
(base) root@c07d5cb47355:/# conda env list
# conda environments:
#
base * /root/anaconda3
8.查看系统现在的环境变量
root@c07d5cb47355:/# source ~/anaconda3/bin/activate
(base) root@c07d5cb47355:/# echo $PATH
/root/anaconda3/bin:/root/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9.密钥
(base) root@2d266a8bf1be:/# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:cu2W93w7/ytuSz18O3GDFBabtibH6HHaBG8lsDsalsI root@2d266a8bf1be
The key's randomart image is:
+---[RSA 3072]----+
| . .. |
| ooo |
| o.=.. |
| . .. B.+ |
| .ES+.*.X. |
| oo.+.%.oo.|
| .+o.o +=|
| . ..= o=|
| oo==X|
+----[SHA256]-----+
10.安装pytorch-cpu
#可以在pytorvh官网选择合适的版本,
conda install pytorch-cpu torchvision-cpu -c pytorch
#完成后检验是否有错误:
python
import torch
import torchvision
#若没有报错则完成。
11.