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.
http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html
Remove Untagged Images From Docker的更多相关文章
- [Angular CLI] Build application without remove dist folder for Docker Volume
		When we develop the Angular app inside Docker container, we can simulate Production envioment by bui ... 
- how to remove untagged / none images
		docker rmi $(docker images -a| grep "^<none>" | awk '{print $"3"}') 
- Centos6.5下docker 环境搭建
		一.运行docker Linux内核版本需要在3.8以上,针对centos6.5 内核为2.6的系统需要先升级内核.不然会特别卡,退出容器. 在yum的ELRepo源中,有mainline(3.13. ... 
- docker好文收藏
		深入浅出Docker(一):Docker核心技术预览 2. 核心技术预览 Docker核心是一个操作系统级虚拟化方法, 理解起来可能并不像VM那样直观.我们从虚拟化方法的四个方面:隔离性.可配额/可度 ... 
- docker offical docs:Working with Docker Images
		Working with Docker Images ##orignal is always the best In the introduction we've discovered that Do ... 
- docker operation method  note
		docker stop script #!/bin/bash CID_LIST=$(docker ps -q | xargs)if [ "$CID_LIST" = "&q ... 
- Docker 基础 (一)
		为什么要使用 Docker? 作为一种新兴的虚拟化方式,Docker 跟传统的虚拟化方式相比具有众多的优势.首先,Docker 容器的启动可以在秒级实现,这相比传统的虚拟机方式要快得多. 其次,Doc ... 
- docker rmi命令-删除image
		rmi 删除image Usage: docker rmi IMAGE [IMAGE...]Remove one or more images -f,--force=falseForce remova ... 
- Centos7 docker 常用指令
		Docker 运行在 CentOS 7 上,要求系统为64位.系统内核版本为 3.10 以上 一.docker的安装及卸载 1.查看当前系统内核版本: [root@docker ~]# uname - ... 
随机推荐
- [原创]KVM虚拟化管理平台的实现
			KVM虚拟化管理平台的实现 源码链接:https://github.com/wsjhk/IaaS_admin.git 根据KVM虚拟化管理的要求,设计并实现网页操作管理KVM虚拟机.设计原理架构如下图 ... 
- ZOJ2724 Windows Message Queue 裸queue的模拟
			题目要求FIFO #include<cstdio> #include<cstdlib> #include<iostream> #include<queue&g ... 
- JavaScript享元模式
			通过两个例子的对比来凸显享元模式的特点:享元模式是一个为了提高性能(空间复杂度)的设计模式,享元模式可以避免大量非常相似类的开销. 第一实例,没有使用享元模式,计算所花费的时间和空间使用程度. 要求为 ... 
- C# To JAVA Converter Cracked ( 破解版 )
			C# To JAVA Converter v17.10.6 Cracked by X-Cracker 简介 C# To Java converter是一款将C#代码片段或者C#项目转换为JAVA的工 ... 
- [maven(1)]myeclipse2014下如何配置maven
			1.maven工程下载,解压压缩包到某一目录中 2.配置环境变量 在电脑环境变量中新建M2_HOME M2_HOME:D:\MAVEN\apache-maven-3.3.9(类似Java_Home) ... 
- JS难点--组件开发
			p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Consolas; color: #a5b2b9 } span.Apple-tab-span ... 
- web项目生成war包的问题
			今天面试一家公司,问我生成war包的命令是什么? 当时没明白,就说自己用的eclipse直接右键 export --->war 完了重启tomcat(第一种) 好久没用maven了.回来一查才明 ... 
- PHP的取整函数
			PHP的取整函数有四个,分别是ceil.floor.round和intval,下面对它们进行一一介绍: 1. ceil(x):向上舍入为最接近的整数. 返回不小于 x 的下一个整数,x 如果有小数部分 ... 
- java web 入门级 开发 常用页面调试方法
			这里介绍一下Java web 入门级开发中常用的代码调式方法; ( 仅供入门级童靴 参考) ; 工具: chrome 浏览器 (版本越高越好); Java web 入门级开发 主要就是两个方面: ... 
- MQTT——控制报文格式
			解控制报文格式是学习MQTT中,笔者认为最为重要的一个知识点.MQTT的所有行为都离不开他.控制报文可以分为三个部分组成,分别为:固定报头.可以变报头.有效载荷部分. 注意:上面的说的报文的类型.是指 ... 
