gpt4 book ai didi

docker - 如何在Docker镜像中查看文件(示例:Docker的 'hello-world'镜像)

转载 作者:行者123 更新时间:2023-12-02 21:14:44 26 4
gpt4 key购买 nike

我是Docker的新手,并且正在对官方Docker docker inspect镜像进行hello-world的操作,以下是其摘录:

C:\> docker inspect hello-world
[
{
"Id": "sha256:2cb0d9787c4dd17ef9eb03e512923bc4db10add190d3f84af63b744e353a9b34",
"RepoTags": [
"hello-world:latest"
],
"RepoDigests": [
"hello-world@sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc"
],
"Parent": "",
"Comment": "",
"Created": "2018-07-11T00:32:08.432822465Z",
"Container": "6b6326f6afc81f7850b74670aad2bf550c7f2f07cd63282160e5eb564876087f",
"ContainerConfig": {
"Hostname": "6b6326f6afc8",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/hello\"]"
],
"ArgsEscaped": true,
"Image": "sha256:6bc48d210ad4c6bbb74e02e6196a9133b57107033c09e92cac12616cad30ebcf",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"DockerVersion": "17.06.2-ce",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/hello"
],
"ArgsEscaped": true,
"Image": "sha256:6bc48d210ad4c6bbb74e02e6196a9133b57107033c09e92cac12616cad30ebcf",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 1848,
"VirtualSize": 1848,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/20d0631d9382f954d57631716e227ddbd42a0b383ae5e26241d5cf9fc92cbfe2/merged",
"UpperDir": "/var/lib/docker/overlay2/20d0631d9382f954d57631716e227ddbd42a0b383ae5e26241d5cf9fc92cbfe2/diff",
"WorkDir": "/var/lib/docker/overlay2/20d0631d9382f954d57631716e227ddbd42a0b383ae5e26241d5cf9fc92cbfe2/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:ee83fc5847cb872324b8a1f5dbfd754255367f4280122b4e2d5aee17818e31f5"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]

问题:
  • 我以为需要定义一个Entrypoint来使容器可执行(这样,当我执行docker run hello-world时,您会看到通常看到的文本 Blob ),但是在下面的输出中,我看到Entrypoint是null。有任何想法吗?
  • 我可以想象,如果我以交互方式运行容器,则可以深入文件系统以查看文件,但是hello-world图像在交互模式下不起作用。
  • 最佳答案

    在Docker中运行可执行文件有两种方法

  • CMD
  • ENTRYPOINT

  • 每个可运行的docker镜像都需要CMD或ENTRYPOINT。
    它们在容器根命令的形式上略有不同。
    this question的差异
    否则,出于所有实际目的,它们是相同的

    从hello-world图片中可以看到,它的 CMD指定为 /hello

    关于docker - 如何在Docker镜像中查看文件(示例:Docker的 'hello-world'镜像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51936238/

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