Docker 删除镜像

落日映苍穹つ 2022-05-27 04:18 332阅读 0赞

Docker删除镜像的前提是镜像没有被使用,没有被使用需要确定容器中确实没有引用镜像,包括停止的容器。

关于删除docker镜像的参考链接
Docker 容器镜像删除
关于一些options的解释

  1. Options:
  2. -a, --all Show all images (default hides intermediate images) --digests Show digests -f, --filter filter Filter output based on conditions provided --format string Pretty-print images using a Go template --no-trunc Don't truncate output -q, --quiet Only show numeric IDs

停用全部运行中的容器:

  1. docker stop $(docker ps -q)

删除全部容器:

  1. docker rm $(docker ps -aq)

删除全部image

  1. docker rmi $(docker images -q)

删除id为的image

  1. docker rmi $(docker images | grep "^<none>" | awk "{print $3}")

备注:
1、删除镜像之前需要先停掉容器,并且要删掉容器。
2、需要注意删除镜像和容器的命令不一样。 docker rmi ID ,其中 容器(rm) 和 镜像(rmi)
3、顺序需要先删除容器


查看容器命令

命令记录

列出正在运行的容器ID

  1. [root@localhost ~]# docker ps -q
  2. 69c85cfdfebc

列出所有容器的ID

  1. [root@localhost ~]# docker ps -q
  2. 69c85cfdfebc

列出所有容器 包括停止的容器

  1. [root@localhost ~]# docker container ls --all
  2. 或者
  3. [root@localhost ~]# docker ps -a

列出正在运行的容器

  1. [root@localhost ~]# docker container ls
  2. 或者
  3. [root@localhost ~]# docker ps

查看docker容器的虚拟IP

  1. [root@localhost geth]# docker container inspect 69c85cfdfebc |grep IPAddress
  2. 后面不添加grep IPAddress就是查看容器的检视信息。很多..

发表评论

表情:
评论列表 (有 0 条评论,332人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Docker 删除镜像

    > Docker删除镜像的前提是镜像没有被使用,没有被使用需要确定容器中确实没有引用镜像,包括停止的容器。 关于删除docker镜像的参考链接 [Docker 容器镜像删