2017-04-11 53 views
0

Ubuntu 14.04的docker鏡像的大小較大,並且有lsb_release命令。如何調查Ubuntu的兩個Docker鏡像之間的差異?

$ docker run -it ubuntu:14.04 
[email protected]:/# lsb_release -a 
No LSB modules are available. 
Distributor ID: Ubuntu 
Description: Ubuntu 14.04.5 LTS 
Release: 14.04 
Codename: trusty 
[email protected]:/# exit 
exit 
$ docker images ubuntu:14.04 
REPOSITORY   TAG     IMAGE ID   CREATED    SIZE 
ubuntu    14.04    7c09e61e9035  6 weeks ago   188 MB 

Ubuntu的16.04的搬運工圖像尺寸較小,並且不具有 的lsb_release命令。

$ docker run -it ubuntu:16.04 
[email protected]:/# lsb_release -a 
bash: lsb_release: command not found 
[email protected]:/# exit 
exit 
$ docker images ubuntu:16.04 
REPOSITORY   TAG     IMAGE ID   CREATED    SIZE 
ubuntu    16.04    0ef2e08ed3fa  6 weeks ago   130 MB 

從他們的Dockerfiles開始,我怎樣才能找到導致這種差異的原因的底部?

+0

如果你真正實際的問題是:「我有什麼可以做的」,解決的辦法是insstall包['LSB-release'(http://packages.ubuntu.com/xenial/lsb-發佈) – tripleee

回答

3

這是兩個圖像的Dockerfiles。

下面是這兩個文件之間的唯一區別。

-ADD ubuntu-trusty-core-cloudimg-amd64-root.tar.gz/
+ADD ubuntu-xenial-core-cloudimg-amd64-root.tar.gz/

所以現在我們從

事實上lsb_release包含在值得信賴的,但不是在xenial同時下載。tar.gz的文件。

$ tar -tf ubuntu-trusty-core-cloudimg-amd64-root.tar.gz | grep lsb_release$ 
usr/bin/lsb_release 
$ tar -tf ubuntu-xenial-core-cloudimg-amd64-root.tar.gz | grep lsb_release$ 
$ 

然後我們提取兩個tarball的內容到目錄,我們可以確認trusty比xenial大。

$ mkdir trusty xenial 
$ tar -xf ubuntu-trusty-core-cloudimg-amd64-root.tar.gz -C trusty 
$ tar -xf ubuntu-xenial-core-cloudimg-amd64-root.tar.gz -C xenial 
$ du -sh trusty xenial 
208M trusty 
141M xenial