当前位置: 首页 > news >正文

Remove Untagged Images From Docker

I’ve been playing around a lot with docker. It’s awesome, and it creates a whole new world of possibilities, and I’m constantly coming up with new ideas of where it could be useful.

After playing with docker for about a week on my development server, I logged in to find that my disk was completely full. I guess after dynamically spinning up dozens of containers, and building a bunch of projects with Dockerfiles I had accumulated quite a few stopped containers and untagged images. I suspect the build process to be the biggest contributor to this, as each step in your dockerfile creates a new container, which serves as the base for the next step. This is usfeul because it can cache the containers and speed up builds, but it does consume a bit of space.

I was not able to find any built-in commands for clearing stopped containers and untagged images, so I was able to put together a couple commands.

Remove all stopped containers.

docker rm $(docker ps -a -q)

This will remove all stopped containers by getting a list of all containers with docker ps -a -q and passing their ids to docker rm. This should not remove any running containers, and it will tell you it can’t remove a running image.

Remove all untagged images

In the process of running docker I had accumulated several images that are not tagged. To remove these I use this command:

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

This works by using rmi with a list of image ids. To get the image ids we call docker images then pipe it to grep "^<none>". The grep will filter it down to only lines with the value “<none>” in the repository column. Then to extract the id out of the third column we pipe it to awk "{print $3}" which will print the third column of each line passed to it.

After running these two commands I recovered 15G of space. There may be more I could do to recover more space, my docker graph directory still is over 5G, but for now this works.

from:http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html

相关文章:

  • Error creating bean with name 'adminUserController': Injection of autowired dependencies failed;
  • [技术选型] spring boot
  • 学习JavaScript数据结构与算法 — 树
  • shell第一列相同即判断为重复,只取其中一条数据
  • BZOJ 4767: 两双手 [DP 组合数]
  • linux 调试 之printf
  • 普通函数和构造函数的区别
  • jwplayer 隐藏属性方法记载
  • hadoop2.7.3 HA高可用集群安装
  • lcx转发
  • 分布式数据库
  • github指令
  • Mysql 死锁
  • Centos Svn 仓库部署
  • 编码规范
  • ES6指北【2】—— 箭头函数
  • Angular数据绑定机制
  •  D - 粉碎叛乱F - 其他起义
  • FineReport中如何实现自动滚屏效果
  • JS+CSS实现数字滚动
  • MyEclipse 8.0 GA 搭建 Struts2 + Spring2 + Hibernate3 (测试)
  • python 学习笔记 - Queue Pipes,进程间通讯
  • Sass Day-01
  • vuex 学习笔记 01
  • 大快搜索数据爬虫技术实例安装教学篇
  • 关于 Cirru Editor 存储格式
  • 基于组件的设计工作流与界面抽象
  • 极限编程 (Extreme Programming) - 发布计划 (Release Planning)
  • 开源中国专访:Chameleon原理首发,其它跨多端统一框架都是假的?
  • 快速构建spring-cloud+sleuth+rabbit+ zipkin+es+kibana+grafana日志跟踪平台
  • 突破自己的技术思维
  • 微信开放平台全网发布【失败】的几点排查方法
  • 学习使用ExpressJS 4.0中的新Router
  • 《天龙八部3D》Unity技术方案揭秘
  • LIGO、Virgo第三轮探测告捷,同时探测到一对黑洞合并产生的引力波事件 ...
  • 蚂蚁金服CTO程立:真正的技术革命才刚刚开始
  • ​ 轻量应用服务器:亚马逊云科技打造全球领先的云计算解决方案
  • ​用户画像从0到100的构建思路
  • ![CDATA[ ]] 是什么东东
  • # 数论-逆元
  • #define用法
  • #Java第九次作业--输入输出流和文件操作
  • #Linux(权限管理)
  • $(function(){})与(function($){....})(jQuery)的区别
  • (13)[Xamarin.Android] 不同分辨率下的图片使用概论
  • (2)MFC+openGL单文档框架glFrame
  • (4) PIVOT 和 UPIVOT 的使用
  • (6)设计一个TimeMap
  • (react踩过的坑)Antd Select(设置了labelInValue)在FormItem中initialValue的问题
  • (附源码)spring boot智能服药提醒app 毕业设计 102151
  • (论文阅读22/100)Learning a Deep Compact Image Representation for Visual Tracking
  • (排序详解之 堆排序)
  • (学习日记)2024.02.29:UCOSIII第二节
  • (一)Neo4j下载安装以及初次使用
  • (转)nsfocus-绿盟科技笔试题目