Docker:如何访问图像的Dockerfile?
当我运行docker images命令时,我得到如下所示的列表 [root@hadoop01myjavadir]#docker图像Docker:如何访问图像的Dockerfile?,docker,Docker,当我运行docker images命令时,我得到如下所示的列表 [root@hadoop01myjavadir]#docker图像 REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE runhelloworld latest c49c32235334 18 hours ago
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
runhelloworld latest c49c32235334 18 hours ago 642.2 MB
<none> <none> 6eadaac27986 19 hours ago 642.2 MB
<none> <none> ed95cf58873e 25 hours ago 642.2 MB
<none> <none> ebedbfee37fd 25 hours ago 642.2 MB
<none> <none> 25453e89b3f0 43 hours ago 0 B
priyankapatil/docker-whale latest aa043d321de5 44 hours ago 255.5 MB
helloworld latest aa043d321de5 44 hours ago 255.5 MB
docker-whale latest aa043d321de5 44 hours ago 255.5 MB
java latest 3323938eb5a2 9 days ago 642.2 MB
tomcat7 dockerfile 4b4b09c0dbed 9 days ago 1.289 GB
tomcat7 dockerfile1 4b4b09c0dbed 9 days ago 1.289 GB
tomcat7 latest 4b4b09c0dbed 9 days ago 1.289 GB
docker_image latest 4b4b09c0dbed 9 days ago 1.289 GB
lastest_docker latest 4b4b09c0dbed 9 days ago 1.289 GB
tapash1 latest 4b4b09c0dbed 9 days ago 1.289 GB
<none> <none> 866c370a7562 9 days ago 855.3 MB
<none> <none> 8ca0c468c6ee 9 days ago 598.8 MB
<none> <none> d5f676fa467b 9 days ago 292.5 MB
<none> <none> 459c1c0551e2 9 days ago 265.6 MB
registry 2 1fff2b77d9b3 3 weeks ago 224.5 MB
centos latest 60e65a8e4030 6 weeks ago 196.6 MB
hello-world latest 975b84d108f1 4 months ago 960 B
centos centos6 3bbbf0aca359 4 months ago 190.6 MB
docker/whalesay latest fb434121fc77 8 months ago 247 MB
存储库标记图像ID已创建虚拟大小
runhelloworld最新版本c49c32235334 18小时前642.2 MB
6eadaac27986 19小时前642.2 MB
ed95cf58873e 25小时前642.2 MB
25小时前的ebedbfee37fd 642.2 MB
25453e89b3f0 43小时前0 B
priyankapatil/docker whale最新版本aa043d321de5 44小时前255.5 MB
helloworld最新版本aa043d321de5 44小时前255.5 MB
docker whale最新版本aa043d321de5 44小时前255.5 MB
java最新版本3323938eb5a2 9天前642.2MB
tomcat7 dockerfile 4B4B09C0DB9天前已加载1.289 GB
tomcat7 dockerfile1 4B4B09C0DB9天前已加载1.289 GB
tomcat7最新4B4B09C0DB9天前发布1.289 GB
docker_图像最新4b4b09c0dbed 9天前1.289 GB
最新docker最新4B4B09C0DB9日前发布1.289 GB
tapash1最新4b4B09c0db9天前发布1.289 GB
866c370a7562 9天前855.3 MB
8ca0c468c6ee 9天前598.8 MB
d5f676fa467b 9天前29250 MB
459c1c0551e2 9天前265.6 MB
3周前的注册表2 1FF2B77D9B3 224.5 MB
centos最新版本60E65A8E430 6周前196.6 MB
hello world最新版本975b84d108f1 4个月前960 B
centos centos6 3bbbf0aca359 4个月前为1906 MB
docker/whalesay最新fb434121fc77 8个月前247 MB
如何访问此列表中图像的dockerfile?请参阅centurylinklabs提供的来自图像的dockerfile
docker历史记录
在一张图片上会给你主要的信息,见文档
我写了这个简短的Python脚本,它比图片中的dockerfile要少一点
import subprocess
import sys
def main():
dockid = sys.argv[1]
args = ['docker', 'history', dockid]
proc = subprocess.Popen(args=args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
(stdout, stderr) = proc.communicate()
lines = stdout.split('\n')[1:-2]
lines.reverse()
for line in lines:
idlayer = line.split(' ')[0]
args = ['docker', 'inspect',
"--format", "'{{ ((index .ContainerConfig.Cmd ) 0) }}'",
idlayer]
proc = subprocess.Popen(args=args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
(stdout, stderr) = proc.communicate()
print stdout,
# print idlayer, stdout,
main()
如果有人能帮我的话,我无法正确显示整个Python代码