Docker系列之八:修剪命令

2019-02-25  本文已影响0人  小六的昵称已被使用

title: Docker系列之八:修剪命令
categories: Docker
tags:
- Docker
timezone: Asia/Shanghai
date: 2019-02-25


1.修剪镜像 - 删除dangling 镜像

[root@centos181001 docker]# docker image prune --help

dangling 镜像是没被标记且没被其它任何镜像引用的镜像。要删除 dangling 镜像:

Usage:  docker image prune [OPTIONS]

Remove unused images
删除未使用的镜像,不加参数只会删除所有 dangling 镜像

Options:
  -a, --all             Remove all unused images, not just dangling ones
                        删除所有未使用的图像,而不仅仅是 dangling 图像
                        默认只删除 dangling 镜像

      --filter filter   Provide filter values (e.g. 'until=<timestamp>')
                        过滤

  -f, --force           Do not prompt for confirmation
                        不要提示确认

2.修剪容器 - 删除所有已停止的镜像

[root@centos181001 docker]# docker container prune --help

Usage:  docker container prune [OPTIONS]

Remove all stopped containers
删除所有已停止的镜像

Options:
      --filter filter   Provide filter values (e.g. 'until=<timestamp>')
                        过滤

  -f, --force           Do not prompt for confirmation
                        不要提示确认

3.修剪网络 - 删除所有没有被任何已存在的容器使用的网络

[root@centos181001 docker]# docker network prune --help

Usage:  docker network prune [OPTIONS]

Remove all unused networks
删除所有没有被任何已存在的容器使用的网络
只会删除手动建立的网络,系统默认创建的3个网络不会删除

Options:
      --filter filter   Provide filter values (e.g. 'until=<timestamp>')
                        过滤

  -f, --force           Do not prompt for confirmation
                        不要提示确认

4.修剪卷 - 删除所有未被使用的卷。

[root@centos181001 docker]# docker volume prune --help 

Usage:  docker volume prune [OPTIONS]

Remove all unused local volumes
删除所有未被使用的卷

Options:
      --filter filter   Provide filter values (e.g. 'label=<label>')
  -f, --force           Do not prompt for confirmation

5.修剪一切

[root@centos181001 docker]# 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  删除所有悬空缓存
Are you sure you want to continue? [y/N]
上一篇 下一篇

猜你喜欢

热点阅读