build cache 清理(Docker 资源管理)

平常我们会在docker 构建环境下不断地构建新的镜像,当不断地构建新的镜像的时候总是获取不到需要的镜像,是由于image cache 导致的,本身cache 是为了提升build 速度,其会利用现有的cache 来快速构建新的image,当我们构建 image 有问题可以尝试清理下本地的cache;

# docker system prune --volumes
WARNING! This will remove:
  - all stopped containers  # 释放所有stop 的容器
  - all networks not used by at least one container
  - all volumes not used by at least one container
  - all dangling images # 所有虚悬镜像(dangling image)
  - all dangling build cache # 虚悬镜像(dangling image)缓存

Are you sure you want to continue? [y/N]


# docker system prune --all  清除所有缓存
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache

Are you sure you want to continue? [y/N]



ps

可以build 的时候加上--no-cache 无缓存build

docker-compose up --build -d 

根据Dockerfile重新下载需要的镜像并构建容器,也就是说这句相当于是

docker-compose build --no-cache

docker-compose up -d 

的集合体,意味着构建镜像的时候是根据Dockerfile的最新内容来的,而不会使用缓存,这样就避免了构建镜像时由于缓存造成的影响。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值