Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created timestamp is wrong for newly built docker image #2252

Closed
ravening opened this issue Jan 28, 2020 · 7 comments
Closed

Created timestamp is wrong for newly built docker image #2252

ravening opened this issue Jan 28, 2020 · 7 comments

Comments

@ravening
Copy link

Environment:

  • Jib version: 1.8.0
  • Build tool: Apache Maven 3.6.0
  • OS: Ubuntu 18.04.3 LTS

Description of the issue:
When I build a docker image for spring boot application using jib maven plugin, the creation date says 50 years ago which is really strange

springbootjib latest 008a4f225d1d 50 years ago 141MB

Expected behavior:

Expected behavior: The created date should reflect the latest time when it was created

Steps to reproduce:

  1. Generate a demo spring boot app using an initializer
  2. Add the below content to pom.xml under plugins section
  3. Run the command mvn compile jib:dockerBuild to generate docker image.

jib-maven-plugin Configuration:

<plugins>
    <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
        <version>1.8.0</version>
	<configuration>
            	<to>
               		<image>springbootjib</image>
            	</to>
        </configuration>
    </plugin>
</plugins>

jib-gradle-plugin Configuration:

PASTE YOUR build.gradle CONFIGURATION HERE

Log output:

[INFO]
[INFO] Containerizing application to Docker daemon as springbootjib...
[WARNING] Base image 'gcr.io/distroless/java:8' does not use a specific image digest - build may not be reproducible
[INFO] Using base image with digest: sha256:65d23224482a20dedb62c94d258706f3949c02bd0522a97fee08d17ab38f1813
[INFO]
[INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, com.example.demo.DemoApplication]
[INFO]
[INFO] Built image to Docker daemon as springbootjib
[INFO] Executing tasks:
[INFO] [==============================] 100.0% complete
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  24.565 s
[INFO] Finished at: 2020-01-28T14:01:21Z
[INFO] ------------------------------------------------------------------------

Additional Information:

As can be seen from the above output, the image was created on Finished at: 2020-01-28T14:01:21Z but the docker timestamp is different

springbootjib                                                    latest              008a4f225d1d        50 years ago        141MB
@TadCordle
Copy link
Contributor

This is intended, as the timestamp is wiped to maintain reproducibility. See the FAQ for more details: https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#why-is-my-image-created-48-years-ago

@ppiotrow
Copy link

@TadCordle BTW, JIB builds docker images on it's own to override some parameters like
"Created": "1970-01-91T00:00:00.0Z" to fixed time. Can official docker build daemon's time provider be overridden to fixed instance?

@loosebazooka
Copy link
Member

@ppiotrow are you asking how to set the created when doing docker build?

@ppiotrow
Copy link

@loosebazooka Yes, sorry for asking here in JIB project but I had multiple tabs open while googling for it. The override for "created" in not present in the docker API.

I'd like to copy some JIB functionalities to SBT Native Packager Plugin. We already have layers for dependencies&application classes, but when building on different hosts it gives nothing as long as "created" is not fixed.

@loosebazooka
Copy link
Member

@ppiotrow I don't think the docker cli allows for that (I could be wrong). There is a jib-sbt-plugin developed with the jib-core library by a community member, perhaps that could help with some of your problems? If not you might be able to use jib-core yourself to do what you need?

@ppiotrow
Copy link

I've seen the plugin for sbt and I think it's great that it exists giving people possibility to use JIB. The SBT Native Docker Packager uses official docker daemon to build images. It only misses reseting file timestamps (simple) and images creation time (impossible now) to have reasonable support for reproducible builds. I'll contact docker maintainers to add missing option. Thank you for discussion.

@chanseokoh
Copy link
Member

Just FYI, the created timestamp is a relatively minor issue concerning reproducibility, because it only affects a small metadata JSON. A much bigger problem is that you can't build image layers reproducibility because of changing file timestamps. Therefore, I guess it is far more important to change modification time of actual files on your file system when you use the Docker API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants