删除所有docker图像来清理磁盘

-a删除所有未使用的图像,而不仅仅是悬挂的图像,-f不要提示进行确认
.

0

linux命令:docker image prune prune image docker docker image prunerootopen.com
linux命令:docker image prune prune image docker docker image prunerootopen.com
pidn 2018-06-02 16:44:48
输出
替代方案1 删除所有docker图像来清理磁盘

.

linux命令:docker rmi `docker images -a -q` -q` -a images `docker rmi docker docker rmi `docker images -a -q`rootopen.com
linux命令:docker rmi `docker images -a -q` -q` -a images `docker rmi docker docker rmi `docker images -a -q`rootopen.com
.
输出

评论

相关推荐

当你第一次不记得你是怎么做的时候,建立一个新容器的好方法

linux命令:docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie / runlike [ID_CONTAINER] [ID_CONTAINER] runlike / assaflavie /var/run/docker.sock:/var/run/docker.sock -v --rm run docker docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie / runlike [ID_CONTAINER]rootopen.com
linux命令:docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie / runlike [ID_CONTAINER] [ID_CONTAINER] runlike / assaflavie /var/run/docker.sock:/var/run/docker.sock -v --rm run docker docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie / runlike [ID_CONTAINER]rootopen.com
.

linux命令:docker ps -a --format '{{ .ID }}' | xargs -I {} docker inspect -f '{{ .Name }}{{ printf "\n" }}{{ range .Mounts }}{{ printf "\n\t" }}{{ .Type }} {{ if eq .Type "bind" }}{{ .Source }}{{ end }}{{ .Name }} => {{ .Destination }}{{ end }}{{ printf "\n" }}' {} {} }}' "\n" printf }}{{ end }}{{ .Destination {{ => }} .Name }}{{ end }}{{ .Source }}{{ "bind" .Type eq if {{ }} .Type }}{{ "\n\t" printf }}{{ .Mounts range }}{{ "\n" printf }}{{ .Name '{{ -f inspect docker {} -I xargs | }}' .ID '{{ --format -a ps docker docker ps -a --format '{{ .ID }}' | xargs -I {} docker inspect -f '{{ .Name }}{{ printf "\n" }}{{ range .Mounts }}{{ printf "\n\t" }}{{ .Type }} {{ if eq .Type "bind" }}{{ .Source }}{{ end }}{{ .Name }} => {{ .Destination }}{{ end }}{{ printf "\n" }}' {}rootopen.com
linux命令:docker ps -a --format '{{ .ID }}' | xargs -I {} docker inspect -f '{{ .Name }}{{ printf "\n" }}{{ range .Mounts }}{{ printf "\n\t" }}{{ .Type }} {{ if eq .Type "bind" }}{{ .Source }}{{ end }}{{ .Name }} => {{ .Destination }}{{ end }}{{ printf "\n" }}' {} {} }}' "\n" printf }}{{ end }}{{ .Destination {{ => }} .Name }}{{ end }}{{ .Source }}{{ "bind" .Type eq if {{ }} .Type }}{{ "\n\t" printf }}{{ .Mounts range }}{{ "\n" printf }}{{ .Name '{{ -f inspect docker {} -I xargs | }}' .ID '{{ --format -a ps docker docker ps -a --format '{{ .ID }}' | xargs -I {} docker inspect -f '{{ .Name }}{{ printf "\n" }}{{ range .Mounts }}{{ printf "\n\t" }}{{ .Type }} {{ if eq .Type "bind" }}{{ .Source }}{{ end }}{{ .Name }} => {{ .Destination }}{{ end }}{{ printf "\n" }}' {}rootopen.com
.

linux命令:docker ps -aq --filter status=exited | xargs docker rm rm docker xargs | status=exited --filter -aq ps docker docker ps -aq --filter status=exited | xargs docker rmrootopen.com
linux命令:docker ps -aq --filter status=exited | xargs docker rm rm docker xargs | status=exited --filter -aq ps docker docker ps -aq --filter status=exited | xargs docker rmrootopen.com
.

linux命令:docker image rm $(docker image list -f “dangling = true” -qa) -qa) true” = “dangling -f list image $(docker rm image docker docker image rm $(docker image list -f “dangling = true” -qa)rootopen.com
linux命令:docker image rm $(docker image list -f “dangling = true” -qa) -qa) true” = “dangling -f list image $(docker rm image docker docker image rm $(docker image list -f “dangling = true” -qa)rootopen.com
.

这将清除已停止的容器和它们使用的卷

linux命令:docker system prune --volumes -f -f --volumes prune system docker docker system prune --volumes -frootopen.com
linux命令:docker system prune --volumes -f -f --volumes prune system docker docker system prune --volumes -frootopen.com
.

linux命令:docker images | grep <none> | awk '{ print $3; }' | xargs docker rmi rmi docker xargs | }' $3; print '{ awk | <none> grep | images docker docker images | grep <none> | awk '{ print $3; }' | xargs docker rmirootopen.com
linux命令:docker images | grep <none> | awk '{ print $3; }' | xargs docker rmi rmi docker xargs | }' $3; print '{ awk | <none> grep | images docker docker images | grep <none> | awk '{ print $3; }' | xargs docker rmirootopen.com
.

linux命令:docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull pull docker -L1 xargs | $1}' '{print awk | REPOSITORY -v grep | images docker docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pullrootopen.com
linux命令:docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull pull docker -L1 xargs | $1}' '{print awk | REPOSITORY -v grep | images docker docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pullrootopen.com
.

删除未使用的图像-a删除所有未使用的图像,而不仅仅是悬空图像-f不要提示确认

linux命令:docker image prune prune image docker docker image prunerootopen.com
linux命令:docker image prune prune image docker docker image prunerootopen.com
.

当你运行大量的容器时,内置的docker ps输出变得不可读。 该命令将输出格式化为更容易。 要求q(https://github.com/harelba/q)文本作为数据。

linux命令:docker ps | sed -e 's/ /\+/g' -e 's/CONTAINER ID/CONTAINER_ID/' | tr -s '+' '\t' | q -t 'select c1,substr(c7, 0, 40),c2,c6 from -' | column -t -t column | -' from 40),c2,c6 0, c1,substr(c7, 'select -t q | '\t' '+' -s tr | ID/CONTAINER_ID/' 's/CONTAINER -e /\+/g' 's/ -e sed | ps docker docker ps | sed -e 's/ /\+/g' -e 's/CONTAINER ID/CONTAINER_ID/' | tr -s '+' '\t' | q -t 'select c1,substr(c7, 0, 40),c2,c6 from -' | column -trootopen.com
linux命令:docker ps | sed -e 's/ /\+/g' -e 's/CONTAINER ID/CONTAINER_ID/' | tr -s '+' '\t' | q -t 'select c1,substr(c7, 0, 40),c2,c6 from -' | column -t -t column | -' from 40),c2,c6 0, c1,substr(c7, 'select -t q | '\t' '+' -s tr | ID/CONTAINER_ID/' 's/CONTAINER -e /\+/g' 's/ -e sed | ps docker docker ps | sed -e 's/ /\+/g' -e 's/CONTAINER ID/CONTAINER_ID/' | tr -s '+' '\t' | q -t 'select c1,substr(c7, 0, 40),c2,c6 from -' | column -trootopen.com
.

linux命令:docker kill $(docker ps -q) -q) ps $(docker kill docker docker kill $(docker ps -q)rootopen.com
linux命令:docker kill $(docker ps -q) -q) ps $(docker kill docker docker kill $(docker ps -q)rootopen.com
.

linux命令:docker inspect -f "{{ .NetworkSettings.IPAddress }}" $CONTAINERID $CONTAINERID }}" .NetworkSettings.IPAddress "{{ -f inspect docker docker inspect -f "{{ .NetworkSettings.IPAddress }}" $CONTAINERIDrootopen.com
linux命令:docker inspect -f "{{ .NetworkSettings.IPAddress }}" $CONTAINERID $CONTAINERID }}" .NetworkSettings.IPAddress "{{ -f inspect docker docker inspect -f "{{ .NetworkSettings.IPAddress }}" $CONTAINERIDrootopen.com
.

它需要https://jqplay.org/,这是brew自带的:brew install jq

linux命令:docker ps -q | xargs -n 1 docker inspect | jq '.[0].NetworkSettings.Ports +{} | map(select(. != null)[0].HostPort) | map("-L \(.):localhost:\(.)") ' | sed -n 's/.*"\(.*\)".*/\1/p' |xargs boot2docker ssh -N -N ssh boot2docker |xargs 's/.*"\(.*\)".*/\1/p' -n sed | ' \(.):localhost:\(.)") map("-L | null)[0].HostPort) != map(select(. | +{} '.[0].NetworkSettings.Ports jq | inspect docker 1 -n xargs | -q ps docker docker ps -q | xargs -n 1 docker inspect | jq '.[0].NetworkSettings.Ports +{} | map(select(. != null)[0].HostPort) | map("-L \(.):localhost:\(.)") ' | sed -n 's/.*"\(.*\)".*/\1/p' |xargs boot2docker ssh -Nrootopen.com
linux命令:docker ps -q | xargs -n 1 docker inspect | jq '.[0].NetworkSettings.Ports +{} | map(select(. != null)[0].HostPort) | map("-L \(.):localhost:\(.)") ' | sed -n 's/.*"\(.*\)".*/\1/p' |xargs boot2docker ssh -N -N ssh boot2docker |xargs 's/.*"\(.*\)".*/\1/p' -n sed | ' \(.):localhost:\(.)") map("-L | null)[0].HostPort) != map(select(. | +{} '.[0].NetworkSettings.Ports jq | inspect docker 1 -n xargs | -q ps docker docker ps -q | xargs -n 1 docker inspect | jq '.[0].NetworkSettings.Ports +{} | map(select(. != null)[0].HostPort) | map("-L \(.):localhost:\(.)") ' | sed -n 's/.*"\(.*\)".*/\1/p' |xargs boot2docker ssh -Nrootopen.com
.

Docker - 删除所有未运行的容器

linux命令:docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm rm docker xargs | $1}' '{print awk | 'Exit' grep | -a ps docker docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rmrootopen.com
linux命令:docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm rm docker xargs | $1}' '{print awk | 'Exit' grep | -a ps docker docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rmrootopen.com
.

Docker - 删除未使用的images

linux命令:docker images | grep '' | awk '{print $3}' | xargs docker rmi rmi docker xargs | $3}' '{print awk | '' grep | images docker docker images | grep '' | awk '{print $3}' | xargs docker rmirootopen.com
linux命令:docker images | grep '' | awk '{print $3}' | xargs docker rmi rmi docker xargs | $3}' '{print awk | '' grep | images docker docker images | grep '' | awk '{print $3}' | xargs docker rmirootopen.com
.

#Docker&logstash ...以及(免费)多种在线服务!注册以下服务并使用您的OWN设置进行注册,获得乐趣!可选: -e LOGSTASH_CONFIG_URL = http:// gist ..... * [Papertrail](https://papertrailapp.com/?thank=7cfb38) *[Logentries](https://logentries.com/learnmore?code=c4TEpHn52LKeRN9Yb6Aku8XZQxfWUhws) *制作日志目录,例如/登录MAIN主机像:`mkdir / log && ln -f / var / log / syslog / log / syslog ` *让我们写下som日志! *直接通过tcp写入:`echo das | nc -v YOURHOST 555 ` *使用logstash:`ln -f / var / log .... / log / syslog` *写出调试内容:`echo blablalba> / log / das` ......

linux命令:docker run --name=logstash \ -p 9200:9200 -p 554:514/udp -p 555:514 \ -v /log:/log pblittle/docker-logstash pblittle/docker-logstash /log:/log -v \ 555:514 -p 554:514/udp -p 9200:9200 -p \ --name=logstash run docker docker run --name=logstash \ -p 9200:9200 -p 554:514/udp -p 555:514 \ -v /log:/log pblittle/docker-logstashrootopen.com
linux命令:docker run --name=logstash \ -p 9200:9200 -p 554:514/udp -p 555:514 \ -v /log:/log pblittle/docker-logstash pblittle/docker-logstash /log:/log -v \ 555:514 -p 554:514/udp -p 9200:9200 -p \ --name=logstash run docker docker run --name=logstash \ -p 9200:9200 -p 554:514/udp -p 555:514 \ -v /log:/log pblittle/docker-logstashrootopen.com
.

将停止所有运行的容器,然后删除所有的容器**这不是选择性地处理容器,它删除所有的**

linux命令:docker stop $(docker ps -a -q); docker rm $(docker ps -a -q) -q) -a ps $(docker rm docker -q); -a ps $(docker stop docker docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)rootopen.com
linux命令:docker stop $(docker ps -a -q); docker rm $(docker ps -a -q) -q) -a ps $(docker rm docker -q); -a ps $(docker stop docker docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)rootopen.com
.

linux命令:docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -q) -q) ps $(docker }}" .NetworkSettings.IPAddress "{{ --format inspect docker docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -q)rootopen.com
linux命令:docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -q) -q) ps $(docker }}" .NetworkSettings.IPAddress "{{ --format inspect docker docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -q)rootopen.com
.

linux命令:docker inspect --format "{{ .Name }} # {{ .NetworkSettings.IPAddress }} # {{ .NetworkSettings.Ports }}" $(docker ps -q) | tr -s '#' '\t' '\t' '#' -s tr | -q) ps $(docker }}" .NetworkSettings.Ports {{ # }} .NetworkSettings.IPAddress {{ # }} .Name "{{ --format inspect docker docker inspect --format "{{ .Name }} # {{ .NetworkSettings.IPAddress }} # {{ .NetworkSettings.Ports }}" $(docker ps -q) | tr -s '#' '\t'rootopen.com
linux命令:docker inspect --format "{{ .Name }} # {{ .NetworkSettings.IPAddress }} # {{ .NetworkSettings.Ports }}" $(docker ps -q) | tr -s '#' '\t' '\t' '#' -s tr | -q) ps $(docker }}" .NetworkSettings.Ports {{ # }} .NetworkSettings.IPAddress {{ # }} .Name "{{ --format inspect docker docker inspect --format "{{ .Name }} # {{ .NetworkSettings.IPAddress }} # {{ .NetworkSettings.Ports }}" $(docker ps -q) | tr -s '#' '\t'rootopen.com
.

如果你有很多端口映射,docker ps的输出变得相当模糊。〜120 char单线程将输出转换为更易读的容器列表!

linux命令:docker ps | perl -ple "s/\$/\n\n/g;s/\s{2,}/\n/g;s/(Up)/\\e\[32m\$1\\e\[0m/g;s/(Down)/\\e\[31m\\e\[5m\$1\\e\[25m\\e\[0m/g;s/^([^\n]+)/\\e\[1m\$1\\e\[0m/g;s/(\w+?)$/\\e\[4m\$1\\e\[24m/g" | more more | "s/\$/\n\n/g;s/\s{2,}/\n/g;s/(Up)/\\e\[32m\$1\\e\[0m/g;s/(Down)/\\e\[31m\\e\[5m\$1\\e\[25m\\e\[0m/g;s/^([^\n]+)/\\e\[1m\$1\\e\[0m/g;s/(\w+?)$/\\e\[4m\$1\\e\[24m/g" -ple perl | ps docker docker ps | perl -ple "s/\$/\n\n/g;s/\s{2,}/\n/g;s/(Up)/\\e\[32m\$1\\e\[0m/g;s/(Down)/\\e\[31m\\e\[5m\$1\\e\[25m\\e\[0m/g;s/^([^\n]+)/\\e\[1m\$1\\e\[0m/g;s/(\w+?)$/\\e\[4m\$1\\e\[24m/g" | morerootopen.com
linux命令:docker ps | perl -ple "s/\$/\n\n/g;s/\s{2,}/\n/g;s/(Up)/\\e\[32m\$1\\e\[0m/g;s/(Down)/\\e\[31m\\e\[5m\$1\\e\[25m\\e\[0m/g;s/^([^\n]+)/\\e\[1m\$1\\e\[0m/g;s/(\w+?)$/\\e\[4m\$1\\e\[24m/g" | more more | "s/\$/\n\n/g;s/\s{2,}/\n/g;s/(Up)/\\e\[32m\$1\\e\[0m/g;s/(Down)/\\e\[31m\\e\[5m\$1\\e\[25m\\e\[0m/g;s/^([^\n]+)/\\e\[1m\$1\\e\[0m/g;s/(\w+?)$/\\e\[4m\$1\\e\[24m/g" -ple perl | ps docker docker ps | perl -ple "s/\$/\n\n/g;s/\s{2,}/\n/g;s/(Up)/\\e\[32m\$1\\e\[0m/g;s/(Down)/\\e\[31m\\e\[5m\$1\\e\[25m\\e\[0m/g;s/^([^\n]+)/\\e\[1m\$1\\e\[0m/g;s/(\w+?)$/\\e\[4m\$1\\e\[24m/g" | morerootopen.com
.

linux命令:docker images | awk '{ print $3 }' | grep -v IMAGE | xargs docker rmi rmi docker xargs | IMAGE -v grep | }' $3 print '{ awk | images docker docker images | awk '{ print $3 }' | grep -v IMAGE | xargs docker rmirootopen.com
linux命令:docker images | awk '{ print $3 }' | grep -v IMAGE | xargs docker rmi rmi docker xargs | IMAGE -v grep | }' $3 print '{ awk | images docker docker images | awk '{ print $3 }' | grep -v IMAGE | xargs docker rmirootopen.com
.
共收录0条命令行
这里是记录和分享命令行的地方, 所有命令行都可以进行评论、提交替代方案.

推荐
    热门命令