恢复apt-get update(在docker容器中)

我正在与docker工作,并希望创build一个最小的新层,通过安装一个应用程序在Ubuntu的图像顶部的zip文件。 Ubuntu的映像既没有安装wget也没有解压缩,所以我通过使用apt-get来安装,这需要apt-get update

 docker run -it --name app_container ubuntu:latest # now i have terminal access to the fresh app_container # install wget and unzip apt-get update apt-get install wget -y apt-get install unzip -y # download and unpack the app # ... # remove wget and unzip apt-get purge unzip apt-get purge wget # i need to remove some dependencies of wget that are no longer needed apt-get autoremove 

在这一点上,如果新Docker层的唯一内容是新的应用程序,但是仍然有apt-get update创build/更新的文件,那将是非常好的。 我试图通过使用删除那些

 apt-get clean 

但是

 docker diff app_container 

透露那里有很多更改的文件(不属于该应用程序)。 好吧,那些大小可以忽略不计(主要是/etc/ssl/var/lib/dpkg/info一些残余的wget证书和/var/lib/app/lists 23MB的归档文件),但是本质上是最清晰的可能的docker层:是否有一个聪明的方法来删除这些呢? (“聪明”的意思,而不诉诸暴力)

似乎没有更好的build议,而不是从/ var / lib / app / lists中删除所有内容