清茶书香

一杯清茶,一本书籍,一个下午。


  • 首页

  • 归档

  • 分类

  • 关于

  • 搜索
Redis JPA Solr SpringData SpringMVC localRepository local Mapper 事务 Mybatis JDBC AOP DI IOC 常用函数 触发器 存储过程 Promise Gateway SpringCloud vue-cli axios es6 webpack npm vue 个性化 zsh 终端 caffeine jvm缓存 guava cache validation Mapping MapStruct comment 小程序 建站 WeHalo config logback plugins database idea maven spring https http nginx password RabbitMQ 秒杀系统 Windows MySQL 数据备份 halo SpringBoot shell Linux ip Optional Stream Lambda k8s Docker 列编辑 vim MacOS 图片合成 Java 远程联调 nps 内网穿透

清理docker镜像

发表于 2022-01-07 | 分类于 Docker | 0 | 阅读次数 1781

docker使用时间长了总会产生一些临时镜像,这些镜像一般不被用到,这篇就记录一些清理docker镜像或容器等的命令。

清理镜像

  • docker image prune 清理没有被使用的镜像(<none>标签的镜像,这些镜像被称为dangling image)
  • docker image prune -a清理没有容器使用的镜像(慎用!会删除那些用来做版本回退的镜像)
  • docker image prune -f或者用--force参数跳过警告,直接删除
  • docker image prune --filter "until=240h"过滤删除,删除创建时间超过10天的并且未使用的镜像。
# 使用format命令格式化镜像表格信息
$ docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}'


REPOSITORY             TAG                 IMAGE ID            CREATED AT                      SIZE
halohub/halo           1.4.16              b7b9923025c2        2021-12-12 20:22:44 +0800 CST   325MB
redis                  latest              bc8d70f9ef6c        2021-05-13 03:07:40 +0800 CST   105MB
busybox                latest              f35646e83998        2020-10-13 16:39:44 +0800 CST   133MB

#这样就可以使用具体时间的过滤方式
$ docker image prune -a --force --filter "until=2017-01-04T00:00:00"

更多关于filter参数可参考Docker-docs

清理容器

docker container prune [OPTIONS]
OPTIONSDESC
--force,-f不提示删除
--filter过滤删除,如:--filter "until=20h"

清理卷

docker volume prune [OPTIONS]
OPTIONSDESC
--force,-f不提示删除
--filter过滤删除,如:--filter "until=20h"

清理网络

docker network prune [OPTIONS]
OPTIONSDESC
--force,-f不提示删除
--filter过滤删除,如:--filter "until=20h"

清理系统

docker system prune [OPTIONS]
OPTIONSDESC
-a清理没有容器使用的镜像
--force,-f不提示删除
--filter过滤删除,如:--filter "until=20h"
--volumes清理卷(默认不清理卷)
$ docker system prune

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

$ docker system prune --volumes

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all volumes not used by at least one container
  - all dangling images
  - all dangling build cache
Bennett wechat
欢迎收藏我的微信小程序,方便查看更新的文章。
  • 本文作者: Bennett
  • 本文链接: https://hibennett.cn/archives/docker-prune
  • 版权声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0 许可协议。转载请注明出处!
# Docker
命令查看图片的16进制信息
vue学习记录之vue路由组件vue-router
  • 文章目录
  • 站点概览
Bennett

Bennett

60 日志
28 分类
74 标签
RSS
Github E-mail Gitee QQ
Creative Commons
Links
  • MacWk
  • 知了
0%
© 2020 — 2023 hibennett.cn版权所有
由 Halo 强力驱动
|
主题 - NexT.Pisces v5.1.4

浙公网安备 33010802011246号

    |    浙ICP备2020040857号-1