Skip to content

"Created" in image inspect response is not a valid date/time if "created" is absent in the image config #47368

@SgtSilvio

Description

@SgtSilvio

Description

The created field in an image config is optional according to the OCI Image Format Specification (https://github.com/opencontainers/image-spec/blob/main/config.md#properties).

The Created field in a image inspect api response (/images/{name}/json) is a date and time in RFC 3339 format
(https://github.com/moby/moby/blob/master/docs/api/v1.44.yaml#L1742-L1745).

If the created field is now absent in an image's config - which is valid as described above - (for example in the hivemq/hivemq-swarm:4.25.0 image), the Created field in the image inspect response is not a valid date and time but an empty string since version 25.x.

  • Docker version 24.0.7: "Created":"0001-01-01T00:00:00Z"
  • Docker version 25.0.3: "Created":""

Is this change intentional?
Instead of an empty string, I would have expected the Created field to be absent in an image inspect response in this case.
It was unexpected that a docker update results in the testcontainers software breaking with a DateTimeParseException: testcontainers/testcontainers-java#8302

Furthermore, the creation time now seems to be more inconsistent between the image list and image inspect api responses.

  • Docker version 24.0.7: -62135596800 == "0001-01-01T00:00:00Z"
  • Docker version 25.0.3: 0 vs ""

Reproduce

  1. Docker version 24.0.7:
    1. docker image inspect hivemq/hivemq-swarm:4.25.0
      => "Created": "0001-01-01T00:00:00Z"
    2. curl --unix-socket /var/run/docker.sock http://v1.41/images/hivemq/hivemq-swarm:4.25.0/json
      => "Created":"0001-01-01T00:00:00Z"
    3. docker image list
      => CREATED = N/A
    4. curl --unix-socket /var/run/docker.sock http://v1.41/images/json
      => "Created":-62135596800
  2. Docker version 25.0.3:
    1. docker image inspect hivemq/hivemq-swarm:4.25.0
      => "Created": ""
    2. curl --unix-socket /var/run/docker.sock http://v1.41/images/hivemq/hivemq-swarm:4.25.0/json
      => "Created":""
    3. docker image list
      => CREATED = 54 years ago
    4. curl --unix-socket /var/run/docker.sock http://v1.41/images/json
      => "Created":0

Expected behavior

The behavior of the Created fields in the api responses should be defined for the case when the created field is absent in the image config.
While the previous behavior was not ideal (negative timestamp), it was at least consistent and did not violate the date/time format.

docker version

Client: Docker Engine - Community
 Version:           25.0.3
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        4debf41
 Built:             Tue Feb  6 21:13:09 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.3
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       f417435
  Built:            Tue Feb  6 21:13:09 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    25.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.5
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 25.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-60-generic
 Operating System: Ubuntu 22.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.63GiB
 Name: gradle-agent-1677767724950
 ID: 9299a426-4db0-424c-a2e8-4543fd9005ea
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiAPIkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.status/0-triageversion/25.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions