晒晒我家小院子

0%

Docker镜像瘦身

介绍

  • 使用docker-slim来给docker镜像瘦身

安装

1
2
docker pull dslim/docker-slim
brew install docker-slim

使用

1
2
3
4
5
docker-slim build --from-dockerfile build/docker/Dockerfile --tag lukelau/laumonkey:release-8-g95cdcb3 .
# docker-slim build --help
docker-slim build --from-dockerfile build/docker/Dockerfile --tag lukelau/laumonkey:release-8-g95cdcb3 .
docker-slim build --target ccr.ccs.tencentyun.com/zsyltest/edu:frontend_20210818104832 --tag frontend:test --http-probe=false
2be29257fafc

注意事项

1
2
3
4
--include-path参数的使用
Docker-Slim默认压缩会把镜像里面的一些核心文件、文件夹删掉,会导致压缩后的镜像在容器中运行时报错,用--include-path参数可以解决该问题,保护路径不被剔除
# 示例
docker-slim build --http-probe=false --include-path=/var/lib/mysql-files --include-path=/var/run/mysqld mysql:5.7
-------------本文结束感谢您的阅读-------------