对python:3.7.0-test镜像缩容
[root@172-20-8-243 ~]# docker images | grep python
python 3.7.0-test 3479d86415d5 6 hours ago 3.97GB
python 3.10 d9122363988f 3 months ago 1GB
python 3.7.0 a187104266fb 4 years ago 923MB
安装docker-slim
docker pull dslim/slim
使用slim build优化python:3.7.0-test镜像
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --http-probe=false --include-shell=true --include-path=/usr --include-path=/sbin --include-path=/bin --include-path=/lib python:3.7.0-test
参数解释
--http-probe 启用或禁用http探测(默认值:true)
--include-shell 保留基本shell功能(默认值:false)
--include-path 保留的目录路径,不对这些目录瘦身
瘦身后生成一个.slim后缀镜像
[root@172-20-8-243 ~]# docker images | grep python
python.slim latest 8dccf3feaa4a 4 hours ago 910MB
python 3.7.0-test 3479d86415d5 6 hours ago 3.97GB
python 3.10 d9122363988f 3 months ago 1GB
python 3.7.0 a187104266fb 4 years ago 923MB