gpt4 book ai didi

docker - docker inspect 的 Config 和 ContainerConfig 有什么不同?

转载 作者:IT老高 更新时间:2023-10-28 12:37:56 26 4
gpt4 key购买 nike

我使用 docker inspect 来获取图像信息。我发现输出中有 ConfigContainerConfig,除了 CMD 之外,大多数值都是相同的。

实际上,Config 生效。因为我必须在运行命令中添加 cmd 。
$ docker run -it debian bash

不知道这两个项目有什么区别?

$ docker inspect debian
[
{
"Id": "7abab0fd74f97b6b398a1aca68735c5be153d49922952f67e8696a2225e1d8e1",
......
"ContainerConfig": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"/bin/bash\"]"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"Config": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/bash"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
......
}
]

最佳答案

issue 18880 中所述,关于ContainerConfig:

What you're seeing there is related to the history of how the image was created.
Try running docker history ... on your image and you'll see the complete history.
Docker will place the Dockerfile commands into the CMD section as a way of keeping track of how that layer/container was created.
Its really only used for cache-lookup purposes (internal docker processing) and not meant to be used by the user.

image/image.go 中也可见如:

// ContainerConfig is the configuration of the container that is committed into the image
ContainerConfig container.Config `json:"container_config,omitempty"`

例如,issue 17780说明了一个空的 ContainerConfig:

The ContainerConfig of an image is the container the image was generated from.
In the case of your image, it wasn't generated from a container, but from running docker import.

关于docker - docker inspect 的 Config 和 ContainerConfig 有什么不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36216220/

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