1.参考博客:
1.
docker的安装使用,及打包深度学习环境【很详细】_docker打包环境_明里MX的博客-CSDN博客
2.
Docker打包深度学习项目(解决:Opencv依赖库、共享内存) - 知乎
3
5.使用conda pack进行环境迁移(步骤很详细)_小舟%的博客-CSDN博客
6.使用nvidia-docker创建gpu支持深度学习环境的容器_蔡逸超的博客-CSDN博客
2.普通Docker和NVIDIA Docker安装
不同平台的Docker安装方式可以参考官方文档(Docker Install) ,我这里就用Ubuntu系统作为例子。
1.Install Docker Engine on Ubuntu | Docker Documentation
# Docker
#在首次在新的主机上安装Docker Engine之前,需要设置Docker存储库。之后,您可以从存储库中安装和更新Docker。
#1、更新apt包索引并安装包,以允许apt通过HTTPS使用存储库:
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
#2. 添加Docker的官方GPG密钥:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#添加docker官方gpg密钥,这里改成中科大镜像的
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
#3、使用以下命令设置存储库:
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#设置稳定版本库,也换成中科大的
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Docker engine,安装docker,默认是安装最新版
#1. 更新apt包索引,安装最新版本的Docker Engine、containd和Docker Compose,或者执行下一步安装具体版本:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
在完成安装后,执行下面命令,以确保安装成功:
sudo docker run hello-world
执行后看到打印出来正常的提示信息则表示安装成功。
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
7. 卸载
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd