Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Image Timestamp Issue

I've created a brand new image but it shows 50 years ago timestamp, please find attached the snippet. Any idea why?

I used the below steps in Dockerfile

FROM openjdk:11

VOLUME /tmp

COPY build/libs /app

ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app/test-service.jar"]

and my docker version is

Docker version 19.03.5, build 633a0ea

Gradle 6.0.1 build tool, and Google Jib plugin to create image

plugins {
    id 'com.google.cloud.tools.jib' version '1.8.0'
}

jib {
    from {
        image = 'openjdk:11'
    }
    to {
        image = 'test-service'
    }
    container {
        jvmFlags = ['-Xms512m', '-Xdebug']
        mainClass = 'com.sample.Application'
    }
    allowInsecureRegistries=true
}

enter image description here

like image 374
parrotjack Avatar asked Jun 11 '26 21:06

parrotjack


2 Answers

That's from Google Jib. For reproducibility they don't set a date, or they explicitly set the date to the zero value, which is the epoch in 1970.

There is a FAQ entry for this: https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#why-is-my-image-created-48-years-ago

For reproducibility purposes, Jib sets the creation time of the container images to the Unix epoch (00:00:00, January 1st, 1970 in UTC). If you would like to use a different timestamp, set the jib.container.creationTime / <container><creationTime> parameter to an ISO 8601 date-time. You may also use the value USE_CURRENT_TIMESTAMP to set the creation time to the actual build time, but this sacrifices reproducibility since the timestamp will change with every build.

Setting creationTime parameter

Maven:

<configuration>
  <container>
    <creationTime>2019-07-15T10:15:30+09:00</creationTime>
  </container>
</configuration>

Gradle:

jib.container.creationTime = '2019-07-15T10:15:30+09:00'
like image 156
BMitch Avatar answered Jun 13 '26 12:06

BMitch


You can keep the build reproducibility of the build but with a more sensible creation time by using the timestamp of the commit which is being build:

def getGitCommitTime() {
    String[] parts = 'git show -s --format=%ci'.execute().text.trim().split(" ")
    return (parts[0]+'T'+parts[1]+parts[2])
}
...
jib.container.creationTime = getGitCommitTime()
like image 28
Stefan Ledent Avatar answered Jun 13 '26 12:06

Stefan Ledent