Image and Container Metadata: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(43 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://github.com/moby/moby/blob/master/image/spec/v1.2.md
=Internal=
=Internal=


* [[Docker_Concepts#Container_Metadata|Concepts - Container]]
* [[Docker_Concepts#Container_Metadata|Container]]
* [[Docker_Concepts#Image_Metadata|Image - Container]]
* [[Docker_Concepts#Image_Metadata|Image]]
* [[Docker Client Operations#Image_Operations|Image Operations]]


=Overview=
=Overview=
Line 8: Line 13:
Generated with [[docker inspect#Overview|docker inspect]], in the form of a JSON array.
Generated with [[docker inspect#Overview|docker inspect]], in the form of a JSON array.


<font color=red>'''TODO''': differences between a container and an image metadata.</font>
The metadata has different semantics whether it was generated for an image or a container, as described below.  Metadata for containers must provide all of the runtime configurations needed to start and restart the image with all of its settings intact.


=Elements=
=Elements=
Line 14: Line 19:
==Id==
==Id==


For images, the unique identifier of the images.
For images, the unique identifier of the image. Also see [[Docker_Concepts#Image_ID|Image ID]].


For containers, the unique identifier of the container.
For containers, the unique identifier of the container.
   
   
  "Id": "sha256:6902f4d604b94bddc603cba267ac61fb86c7602d121fa7cdd0c1f2526897a32e"
  "Id": "sha256:6902f4d604b94bddc603cba267ac61fb86c7602d121fa7cdd0c1f2526897a32e"
==Parent==
For images, the [[#Id|identifier]] of the [[Docker Concepts#Parent_Image|parent image]]. The parent image is the image used in the [[Dockerfile#FROM|FROM]] instruction of the [[Dockerfile]] that was used to build the image.
<font color=orange>There are situations when the 'Parent' value is NOT the Id of the image specified as "FROM". That happens when intermediate images are created during the image build process.</font>
Containers do not have parents.


==RepoTags==
==RepoTags==
Line 27: Line 40:


  "RepoDigests": [ "registry.access.redhat.com/rhscl/postgresql-95-rhel7@sha256:33888776920331bc37ae17692bac043210305aa35ed444cf5eded89f8311d0d7"  ]
  "RepoDigests": [ "registry.access.redhat.com/rhscl/postgresql-95-rhel7@sha256:33888776920331bc37ae17692bac043210305aa35ed444cf5eded89f8311d0d7"  ]
==Parent==


==Comment==
==Comment==
Line 37: Line 48:


==Container==
==Container==
For an image, it may contain the identifier of the temporary container created when the image was built. Docker will create a container during the image construction process, and its identifier will be stored in the image metadata.
==Config==
For an image, it refers to the runtime configuration requirements.
For a container, it contains the runtime configuration options set when the docker run command was executed.
===<span id='Config_Hostname'></span>Hostname===
===<span id='Config_Domainname'></span>Domainname===
===<span id='Config_User'></span>User===
<syntaxhighlight lang='json'>
"Config": {
  "User": "<UID>:<GID>"
}
</syntaxhighlight>
See: {{Internal|Dockerfile#USER|Dockerfile USER}}
===<span id='Config_AttachStdin'></span>AttachStdin===
===<span id='Config_AttachStdout'></span>AttachStdout===
===<span id='Config_AttachStderr'></span>AttachStderr===
===<span id='Config_ExposedPorts'></span>ExposedPorts===
===<span id='Config_Tty'></span>Tty===
===<span id='Config_OpenStdin'></span>OpenStdin===
===<span id='Config_StdinOnce'></span>StdinOnce===
===<span id='Config_Env'></span>Env===
A list containing environment variable definitions:
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"container=oci",
...
===<span id='Config_Cmd'></span>Cmd===
The content of the CMD instruction from the Dockerfile that was used to create the image.
CMD /opt/loop
translates to:
<syntaxhighlight lang='json'>
"Cmd": [
  "/bin/sh",
  "-c",
  "/opt/loop"
]
</syntaxhighlight>
===<span id='Config_ArgsEscaped'></span>ArgsEscaped===
===<span id='Config_Image'></span>Image===
===<span id='Config_Volumes'></span>Volumes===
Specifies the definition of in-container [[Docker_Storage_Concepts#Data_Volume|data volume mount points]]. These are not bound until runtime, when the binding information is specified by
<syntaxhighlight lang='json'>
"Config": {
    "Volumes": {
      "/var/lib/pgsql/data": {}
    },
}
</syntaxhighlight>
===<span id='Config_WorkingDir'></span>WorkingDir===
===<span id='Config_Entrypoint'></span>Entrypoint===
===<span id='Config_OnBuild'></span>OnBuild===
===<span id='Config_Labels'></span>Labels===


==ContainerConfig==
==ContainerConfig==
For an image, it refers to the temporary container created when the [[docker build]] command was executed.


===<span id='ContainerConfig_Hostname'></span>Hostname===
===<span id='ContainerConfig_Hostname'></span>Hostname===
Line 79: Line 175:


==DockerVersion==
==DockerVersion==
For an image, it contains the version of Docker used to create the image.


==Author==
==Author==


==Config==
==Architecture==
 
==Os==
 
==Size==
 
==VirtualSize==
 
For an image, the size of the image in bytes.
 
==GraphDriver==
 
==Mounts==


===<span id='Config_Hostname'></span>Hostname===
The [[Docker_Storage_Concepts#Data_Volume|data volume]] mounts.


===<span id='Config_Domainname'></span>Domainname===
<syntaxhighlight lang='json'>
"Mounts": [
            {
                "Type": "bind",
                "Source": "/data-volumes/postgresql",
                "Destination": "/var/lib/pgsql/data",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
      ],
</syntaxhighlight>


===<span id='Config_User'></span>User===
==RootFS==


===<span id='Config_AttachStdin'></span>AttachStdin===
===Type===


===<span id='Config_AttachStdout'></span>AttachStdout===
"Type": "layers"


===<span id='Config_AttachStderr'></span>AttachStderr===
===Layers===


===<span id='Config_ExposedPorts'></span>ExposedPorts===
[
  "sha256:e1d829eddb62dc49f1c56dbf8acd0c71299b3996115399de853a9d66d81b822f",
  "sha256:02404b4d7e5d89b1383ca346b4462b199128aa4b238c5a2b2c186004ac148ba8",
  "sha256:808f296bc8ac99056e0cbba79e2b253fff2c3c963927be1a9acd182bbc90538e"
]


===<span id='Config_Tty'></span>Tty===
==State==


===<span id='Config_OpenStdin'></span>OpenStdin===
It only shows for containers. It contains various status flags and the process id for the container.


===<span id='Config_StdinOnce'></span>StdinOnce===
==Image==


===<span id='Config_Env'></span>Env===
It only shows for containers. It contains the [[#Id|Id]] of the image this container is running.


===<span id='Config_Cmd'></span>Cmd===
==NetworkSettings==


===<span id='Config_ArgsEscaped'></span>ArgsEscaped===
It only shows for containers. It contains the network environment for the container.


===<span id='Config_Image'></span>Image===
==LogPath==


===<span id='Config_Volumes'></span>Volumes===
It only shows for containers. It contains the system path to this container's log file.


===<span id='Config_WorkingDir'></span>WorkingDir===
==RestartCount==


===<span id='Config_Entrypoint'></span>Entrypoint===
It only shows for containers. It keeps track of the number of times the container has been restarted.


===<span id='Config_OnBuild'></span>OnBuild===
==Name==


===<span id='Config_Labels'></span>Labels===
It only shows for containers. It contains the user defined name for the container.


==Architecture==
==Volumes==


==Os==
It only shows for containers. It defines the volume mapping between the host system and the container.


==Size==
==HostConfig==


==VirtualSize==
It only shows for containers. It contains configuration for how the container will interact with the host system. Includes CPU and memory limits, networking values, or device driver paths.


==GraphDriver==
===Mounts===


==RootFS==
The [[Docker_Storage_Concepts#Data_Volume|data volume]] mounts.


===Type===
<syntaxhighlight lang='json'>
"HostConfig": {
    "Mounts": [
                {
                    "Type": "bind",
                    "Source": "/data-volumes/postgresql",
                    "Target": "/var/lib/pgsql/data"
                }
              ]
}
</syntaxhighlight>


"Type": "layers"
===Memory===


===Layers===
{{Internal|Docker_Container_Downward_API#memory.limit_in_bytes|/sys/fs/cgroup/memory/memory.limit_in_bytes}}


[
[[OpenShift Concepts#Memory_Limit|Memory limit]] in OpenShift.
  "sha256:e1d829eddb62dc49f1c56dbf8acd0c71299b3996115399de853a9d66d81b822f",
  "sha256:02404b4d7e5d89b1383ca346b4462b199128aa4b238c5a2b2c186004ac148ba8",
  "sha256:808f296bc8ac99056e0cbba79e2b253fff2c3c963927be1a9acd182bbc90538e"
]

Latest revision as of 19:33, 2 January 2021

External

Internal

Overview

Generated with docker inspect, in the form of a JSON array.

The metadata has different semantics whether it was generated for an image or a container, as described below. Metadata for containers must provide all of the runtime configurations needed to start and restart the image with all of its settings intact.

Elements

Id

For images, the unique identifier of the image. Also see Image ID.

For containers, the unique identifier of the container.

"Id": "sha256:6902f4d604b94bddc603cba267ac61fb86c7602d121fa7cdd0c1f2526897a32e"

Parent

For images, the identifier of the parent image. The parent image is the image used in the FROM instruction of the Dockerfile that was used to build the image.

There are situations when the 'Parent' value is NOT the Id of the image specified as "FROM". That happens when intermediate images are created during the image build process.

Containers do not have parents.

RepoTags

"RepoTags": [ "registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest" ]

RepoDigests

"RepoDigests": [ "registry.access.redhat.com/rhscl/postgresql-95-rhel7@sha256:33888776920331bc37ae17692bac043210305aa35ed444cf5eded89f8311d0d7"  ]

Comment

Created

"Created": "2017-11-22T15:23:09.730226Z"

Container

For an image, it may contain the identifier of the temporary container created when the image was built. Docker will create a container during the image construction process, and its identifier will be stored in the image metadata.

Config

For an image, it refers to the runtime configuration requirements.

For a container, it contains the runtime configuration options set when the docker run command was executed.

Hostname

Domainname

User

"Config": {
  "User": "<UID>:<GID>"
}

See:

Dockerfile USER

AttachStdin

AttachStdout

AttachStderr

ExposedPorts

Tty

OpenStdin

StdinOnce

Env

A list containing environment variable definitions:

"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"container=oci",
...

Cmd

The content of the CMD instruction from the Dockerfile that was used to create the image.

CMD /opt/loop

translates to:

"Cmd": [
  "/bin/sh",
  "-c",
  "/opt/loop"
]

ArgsEscaped

Image

Volumes

Specifies the definition of in-container data volume mount points. These are not bound until runtime, when the binding information is specified by

"Config": {
    "Volumes": {
       "/var/lib/pgsql/data": {}
    },
}

WorkingDir

Entrypoint

OnBuild

Labels

ContainerConfig

For an image, it refers to the temporary container created when the docker build command was executed.

Hostname

Domainname

User

AttachStdin

AttachStdout

AttachStderr

ExposedPorts

Tty

OpenStdin

StdinOnce

Env

Cmd

ArgsEscaped

Image

Volumes

WorkingDir

Entrypoint

OnBuild

Labels

DockerVersion

For an image, it contains the version of Docker used to create the image.

Author

Architecture

Os

Size

VirtualSize

For an image, the size of the image in bytes.

GraphDriver

Mounts

The data volume mounts.

"Mounts": [
            {
                "Type": "bind",
                "Source": "/data-volumes/postgresql",
                "Destination": "/var/lib/pgsql/data",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
       ],

RootFS

Type

"Type": "layers"

Layers

[
  "sha256:e1d829eddb62dc49f1c56dbf8acd0c71299b3996115399de853a9d66d81b822f",
  "sha256:02404b4d7e5d89b1383ca346b4462b199128aa4b238c5a2b2c186004ac148ba8",
  "sha256:808f296bc8ac99056e0cbba79e2b253fff2c3c963927be1a9acd182bbc90538e"
]

State

It only shows for containers. It contains various status flags and the process id for the container.

Image

It only shows for containers. It contains the Id of the image this container is running.

NetworkSettings

It only shows for containers. It contains the network environment for the container.

LogPath

It only shows for containers. It contains the system path to this container's log file.

RestartCount

It only shows for containers. It keeps track of the number of times the container has been restarted.

Name

It only shows for containers. It contains the user defined name for the container.

Volumes

It only shows for containers. It defines the volume mapping between the host system and the container.

HostConfig

It only shows for containers. It contains configuration for how the container will interact with the host system. Includes CPU and memory limits, networking values, or device driver paths.

Mounts

The data volume mounts.

"HostConfig": {
    "Mounts": [
                {
                    "Type": "bind",
                    "Source": "/data-volumes/postgresql",
                    "Target": "/var/lib/pgsql/data"
                }
              ]
}

Memory

/sys/fs/cgroup/memory/memory.limit_in_bytes

Memory limit in OpenShift.