What is the difference between "ContainerConfig" and "Config" in image?

$ docker image inspect image_name|id

The json data out put from this command output,it include ContainerConfig and Config key. Usually their values are the same when commit a image from a container, but not when build from Dockerfile.
Who knows what difference they have in their use?

Config contains the image’s information. As far as I can tell, ContainerConfig contains the details of the container that was used to build the last layer of the image - it corresponds to the last line in the image’s Dockerfile.

I found that the new container (docker run\create) will apply the data of Config.
Does this mean that ContainerConfig just show the last layer information (commit container or last instruction in Dockerfile) in the image and it no use for new containers?
Although the values of ContainerConfig and Config are mostly the same, maybe Config is made from ContainerConfig.

ContainerConfig is of no use for new containers.

It makes sense that the values are mosly the same, as each stage in a build inherits the metadata from the previous stage. One value which is practically guaranteed to be different is the Cmd.

1 Like