撤消apt获取更新(在docker容器中)

撤消apt获取更新(在docker容器中),docker,apt-get,Docker,Apt Get,我正在与docker合作,希望通过在ubuntu映像上的zip文件中安装一个应用程序来创建一个最小的新层。ubuntu映像既没有安装wget,也没有安装unzip,因此我使用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 unzi

我正在与docker合作,希望通过在ubuntu映像上的zip文件中安装一个应用程序来创建一个最小的新层。ubuntu映像既没有安装wget,也没有安装unzip,因此我使用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
创建/更新的文件。我试图通过使用

apt-get clean
但是

docker diff app_container

发现有很多更改过的文件(这些文件不属于应用程序)。好的,这些文件的大小可以忽略不计(主要是
/etc/ssl
/var/lib/dpkg/info
中的一些剩余wget证书,以及
/var/lib/app/lists
中23MB的存档文件),但本着尽可能干净的docker层的精神:是否也有一种智能的方法来删除这些文件?(“聪明”的意思是不诉诸暴力)似乎没有比从
/var/lib/app/lists
中删除所有内容更好的建议了。似乎没有比从
/var/lib/app/lists
中删除所有内容更好的建议了。apt get update的使用应与同一层中的
rm-rf/var/lib/apt/lists/*

使用此在线工具进行一些优化和清晰性检查:

使用apt get update应与同一层中的
rm-rf/var/lib/apt/lists/*
配对使用

使用此在线工具进行一些优化和清晰性检查:

相关:尝试使用
apt get install进行安装--无安装建议
-最小化docker images链接将删除/var/lib/app/列表中的所有内容,这些内容看起来与实际情况一样好。@user2915097使用
的想法--无安装建议
在没有证书验证的情况下安装wget,因此,我们必须将wget与
--无检查证书
选项一起使用。这是可行的,但不值得,
--无安装建议
似乎使用
apt get autoremove
删除wget的依赖项,修改了与我的初始版本相同的文件。相关:尝试使用
apt get install进行安装--无安装建议
-最小化docker images链接将删除/var/lib/app/列表中的所有内容,这些内容似乎是尽可能好。@user2915097使用
--no-install的想法建议
在没有证书验证的情况下安装wget,因此我们必须将wget与
--no-check-certificate
选项一起使用。这是可行的,但并不真正值得,
--无安装建议
似乎使用
apt get autoremove
删除wget的依赖项,修改的文件数量与我的初始版本相同。