gpt4 book ai didi

docker - Docker:如何访问镜像的Dockerfile?

转载 作者:行者123 更新时间:2023-12-02 19:41:22 26 4
gpt4 key购买 nike

当我运行the command docker images时,我得到如下所示的列表。

[root @ hadoop01 myjavadir]#个docker镜像

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

如何获得此列表中镜像的dockerfile?

最佳答案

从Centurylinklabs的图像中查看dockerfile

https://github.com/CenturyLinkLabs/dockerfile-from-image
docker history
图片上的内容将为您提供主要信息,请参阅文档

https://docs.docker.com/engine/reference/commandline/history/

我写了这个简短的Python脚本,它比dockerfile-from-image少一些

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()

关于docker - Docker:如何访问镜像的Dockerfile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35331988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com