我希望了解更多关于Docker的知识。我是个初学者,对Docker和Linux都非常陌生。因为我的英语不是很好,所以我复制了终端输出的内容。
我有一个大小为516MB的镜像VIRTUAL SIZE。
我在容器中启动bash,并使用wget下载了26MB的数据。下载完成后,我通过commit命令创建了一个新的镜像并保存了所做的更改。此时,镜像的VIRTUAL SIZE为542.5MB,这是正确的。
之后,我再次启动bash,并将该文件删除。但是,当我提交更改后,镜像的VIRTUAL SIZE增加到了542.8MB。
您能告诉我原因吗?
本地镜像:
使用最小的一个并下载文件:
列出活动的容器并从其中创建一个新镜像,以反映容器的变化:
感谢您提前提供的任何帮助。Ed
[fedora_user@fedora-vm ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
tester/mytestfedora latest c0ca83567bdd 4 seconds ago 516 MB
fedora latest 834629358fe2 3 months ago 241.3 MB
使用最小的一个并下载文件:
[fedora_user@fedora-vm ~]$ docker run -i -t tester/mytestfedora /bin/bash
bash-4.3# su dockeres
[dockeres@05ef6e284e32 /]$ cd /home/dockeres/downloads/
[dockeres@05ef6e284e32 downloads]$ wget https://dl.dropboxusercontent.com/u/827503/0_TEMP/Riverbed.zip
--2015-03-31 19:24:47-- https://dl.dropboxusercontent.com/u/827503/0_TEMP/Riverbed.zip
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 54.243.97.104, 54.243.80.193, 50.16.185.28, ...
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|54.243.97.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26177252 (25M) [application/zip]
Saving to: 'Riverbed.zip'
Riverbed.zip 100%[==============================================================>] 24.96M 3.66MB/s in 14s
2015-03-31 19:25:03 (1.78 MB/s) - 'Riverbed.zip' saved [26177252/26177252]
[dockeres@05ef6e284e32 downloads]$ exit
bash-4.3# exit
列出活动的容器并从其中创建一个新镜像,以反映容器的变化:
[fedora_user@fedora-vm ~]$ docker ps -all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
05ef6e284e32 tester/mytestfedora:latest "/bin/bash" 2 minutes ago Exited (0) 6 seconds ago sick_einstein
[fedora_user@fedora-vm ~]$ docker commit 05ef6e284e32 tester/mytestfedora
f122b12e94a32d477f2f2f18c5a5190a9ad5d349109933da65a0cfeff448c822
[fedora_user@fedora-vm ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
tester/mytestfedora latest f122b12e94a3 5 seconds ago 542.5 MB
fedora latest 834629358fe2 3 months ago 241.3 MB
再次访问并删除已下载的文件:
[fedora_user@fedora-vm ~]$ docker run -i -t tester/mytestfedora /bin/bash
[dockeres@fb5ba36692f0 /]$ cd /home/dockeres/downloads/
[dockeres@fb5ba36692f0 downloads]$ rm -f Riverbed.zip
[dockeres@fb5ba36692f0 downloads]$ ls
[dockeres@fb5ba36692f0 downloads]$ exit
bash-4.3# exit
再次列出活动的容器并从它的更改中创建一个新的镜像:
[fedora_user@fedora-vm ~]$ docker ps -all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb5ba36692f0 tester/mytestfedora:latest "/bin/bash" 51 seconds ago Exited (0) 5 seconds ago goofy_yalow
[fedora_user@fedora-vm ~]$ docker commit fb5ba36692f0 tester/mytestfedora
f744e248576d7fa434768a1e1d25625a9654020fe77e12306f304ff5d5ad3e3b
[fedora_user@fedora-vm ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
tester/mytestfedora latest f744e248576d 3 seconds ago 542.8 MB
fedora latest 834629358fe2 3 months ago 241.3 MB
感谢您提前提供的任何帮助。Ed
FROM fedora MAINTAINER edfromhadria <edfromhadria@example.com> RUN su -c 'yum -y install unzip' && su -c 'yum -y install wget' && mkdir /usr/etc && cd /usr/etc/ && wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip && unzip jboss-as-7.1.1.Final.zip && rm -rf jboss-as-7.1.1.Final.zip
这个镜像大小是609.5 MB。没有Dockerfile的镜像大小是:610.2 MB。我做错了什么? - los.adrian