ubuntu 删除容器内没用的包
- 删除多余 apt 包
这些就是依赖的所有动态链接库,接着我们将这些包用 apt-mark 声明为“手工安装的包”,即可阻止 apt purge 的自动卸载。 然后,我们再自动卸载其余没有用到的包即可。完整shell脚本如下:
find /usr/local -type f -executable -exec ldd '{}' ';' \ | awk '/=>/ { print $(NF-1) }' \ | sort -u \ | xargs -r dpkg-query --search \ | cut -d: -f1 \ | sort -u \ | xargs -r apt-mark manual \ ; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;
- 删除容器内 python2
apt-get remove --auto-remove python2.7 apt-get purge --auto-remove python2.7 apt-get autoclea python2.7 whereis python2 # 查看是否存在python2 whereis python2 |xargs rm -frv # 删除python2所有残余文件
https://zhuanlan.zhihu.com/p/526332103