docker使用

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:

  1. display the containers currently running:
    docker ps

  2. display all the containers (even those not running anymore):
    docker ps -a

  3. display the images locally saved:
    docker images

  4. remove a docker container:
    docker stop container_name # if container is running
    docker rm container_name

  5. remove all docker containers (not running anymore):
    docker container prune

  6. remove an image:
    docker rmi image_name

  7. remove all docker images (be very careful with this one!):
    docker image prune -a

  8. 下载镜像:
    如果我们本地没有 ubuntu 镜像,我们可以使用 docker pull 命令来载入 ubuntu 镜像
    docker pull ubuntu

  9. 启动容器
    docker run -it ubuntu /bin/bash
    在这里插入图片描述

    启动和停止容器:
    docker start 容器id
    docker stop 容器id

  10. 进入容器,如果run 的时候使用-d参数,容器在后台,想要进入容器
    在使用 -d 参数时,容器启动后会进入后台。此时想要进入容器,可以通过以下指令进入:

docker attach

docker exec:推荐大家使用 docker exec 命令,因为此命令会退出容器终端,但不会导致容器的停止。

docker attach 1e560fca3906
docker exec -it 243c32535da7 /bin/bash

  1. 导出和导入容器

https://www.runoob.com/docker/docker-container-usage.html

导出本地容器
docker export 1e560fca3906 > ./docker/ubuntu.tar
导入 为 镜像
cat docker/ubuntu.tar | docker import - test/ubuntu:v1

  1. 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

  • 17
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值