docker
1.卸载原有版本docker
参考:
https://cloud.tencent.com/developer/article/2157574
https://docs.docker.com/engine/install/ubuntu/ Uninstall old versions
https://www.orchome.com/16608
参考这三个连接
运行docker version判断是否完全卸载
2.install in ubuntu
参考
https://www.runoob.com/docker/ubuntu-docker-install.html
使用 Docker 仓库进行安装
首先设置仓库,通过https来获取仓库
然后直接安装:
sudo apt-get install docker-ce docker-ce-cli containerd.io
3.常用命令
Introduction to Docker
Here are some fundamental commands you need to know:
-
display the containers currently running:
docker ps -
display all the containers (even those not running anymore):
docker ps -a -
display the images locally saved:
docker images -
remove a docker container:
docker stop container_name # if container is running
docker rm container_name -
remove all docker containers (not running anymore):
docker container prune -
remove an image:
docker rmi image_name -
remove all docker images (be very careful with this one!):
docker image prune -a -
下载镜像:
如果我们本地没有 ubuntu 镜像,我们可以使用 docker pull 命令来载入 ubuntu 镜像
docker pull ubuntu -
启动容器
docker run -it ubuntu /bin/bash
启动和停止容器:
docker start 容器id
docker stop 容器id -
进入容器,如果run 的时候使用-d参数,容器在后台,想要进入容器
在使用 -d 参数时,容器启动后会进入后台。此时想要进入容器,可以通过以下指令进入:
docker attach
docker exec:推荐大家使用 docker exec 命令,因为此命令会退出容器终端,但不会导致容器的停止。
docker attach 1e560fca3906
docker exec -it 243c32535da7 /bin/bash
- 导出和导入容器
https://www.runoob.com/docker/docker-container-usage.html
导出本地容器
docker export 1e560fca3906 > ./docker/ubuntu.tar
导入 为 镜像
cat docker/ubuntu.tar | docker import - test/ubuntu:v1
- docker file的使用
https://xaviervasques.medium.com/quick-install-and-first-use-of-docker-327e88ef88c7
https://towardsdatascience.com/build-and-run-a-docker-container-for-your-machine-learning-model-60209c2d7a7f
4.示例
Develop like a Pro with NVIDIA + Docker + VS Code + PyTorch
https://blog.roboflow.com/nvidia-docker-vscode-pytorch/
https://blog.csdn.net/zhouchen1998/article/details/110679750
https://soulteary.com/2023/03/22/docker-based-deep-learning-environment-getting-started.html