安装docker环境
sudo apt-get update
sudo apt-get install -y docker.io
sudo systemctl enable docker
docker版本查看
sudo docker version
sudo docker info
查看镜像
sudo docker images
sudo docker image ls
查看容器
sudo docker ps
sudo docker ps -a
导入镜像文件
sudo docker load -i file_name.tar
将镜像实例化为容器&运行
sudo docker run --name contain_name -it image_name /bin/bash # 无显卡
sudo docker run --name contain_name -itd image_name # 无显卡
sudo docker run --rm --runtime=nvidia --gpus all image_name nvidia-smi # 测试驱动
sudo docker run --name contain_name -itd --runtime=nvidia --gpus all image_name
启动容器
sudo docker start contain_name
运行容器
sudo docker exec -it contain_name /bin/bash
退出容器
ctrl+d
容器保存为镜像
sudo docker commit contain_id image_name:tag
镜像保存为镜像文件
sudo docker save -o file_name.tar image_name:tag
镜像改名
sudo docker tag old_image_name new_image_name
sudo docker rmi old_image_name
容器改名
sudo docker rename old_contain_name new_contain_name
删除镜像
sudo docker rmi image_name
sudo docker rmi -f image_name
删除容器
docker rm contain_name
docker rm -f contain_name
Appendix:
停止socker
sudo systemctl stop docker
修改配置
sudo vim /etc/docker/daemon.json
重载配置
sudo systemctl daemon-reload
重启docker
sudo systemctl restart docker
标签:name,--,image,sudo,pytorch,contain,镜像,docker
From: https://www.cnblogs.com/haorcao/p/docker-pytorch.html