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

Problems with --reproducible (modified timestamp) #2304

Open
leongross opened this issue Oct 31, 2022 · 1 comment
Open

Problems with --reproducible (modified timestamp) #2304

leongross opened this issue Oct 31, 2022 · 1 comment
Labels
feature/reproducible-digest has-repro kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next. priority/p2 High impact feature/bug. Will get a lot of users happy

Comments

@leongross
Copy link

leongross commented Oct 31, 2022

Actual behavior
Using a minimal Dockerfile and that add an empty file and flag --reproducible results in different build hashes when built multiple times.

Expected behavior
The same hash for the docker images.

To Reproduce
Steps to reproduce the behavior:

  1. Create Dockerfile
FROM ubuntu@sha256:7cfe75438fc77c9d7235ae502bf229b15ca86647ac01c844b272b56326d56184
COPY empty /
  1. Create empty file
touch empty
  1. Run kaniko build
docker run \
    -v "$(pwd)"/context/:/workspace \
    -v "$(pwd)"/config.json:/kaniko/.docker/config.json:ro \
    gcr.io/kaniko-project/executor \
    --reproducible \
    --dockerfile Dockerfile \
    --context dir:///workspace/ \
    --destination <registry> \
    --cache=false

Additional Information

  • Dockerfile: above
    Please provide either the Dockerfile you're trying to build or one that can reproduce this error.
  • Build Context
$ tree
── config.json
├── context
│   ├── Dockerfile
│   └── empty
└── run.sh (containing the command)
  • Kaniko Image: gcr.io/kaniko-project/executor latest 14c90714063c 4 weeks ago 63.1MB

EDIT 1:
Running container-diff does not yield any differences

$ container-diff diff <IMG_0> <IMG_1> --type=history --type=file --type=size                                                                                                                                                                   

-----File-----

These entries have been added to <IMG_0> None

These entries have been deleted from <IMG_0> None

These entries have been changed between <IMG_0> and <IMG_1>: None

-----History-----

Docker history lines found only in <IMG_0>: None

Docker history lines found only in <IMG_1>: None

-----Size-----

Image size difference between <IMG_0> and <IMG_1>: None

Triage Notes for the Maintainers

EDIT 2:
I used diffoscope to inspect the file system layers of the docker containers and found the following differences:

$ sudo diffoscope /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07 /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/
+++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/
├── stat {}
│ @@ -1,8 +1,8 @@
│  
│    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│  Device: 259,3	Links: 4
│  Access: (0710/drwx--x---)  Uid: (    0/    root)   Gid: (    0/    root)
│  
│ -Modify: 2022-10-31 11:25:57.856492186 +0000
│ +Modify: 2022-10-31 11:29:02.389132829 +0000
│   --- /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07/committed
├── +++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/committed
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
│ │  Device: 259,3	Links: 1
│ │  Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ -Modify: 2022-10-31 11:25:57.856492186 +0000
│ │ +Modify: 2022-10-31 11:41:02.903334450 +0000
│   --- /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07/diff
├── +++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/diff
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│ │  Device: 259,3	Links: 2
│ │  Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ +Modify: 2022-10-31 11:25:51.046396023 +0000
│ │ -Modify: 2022-10-31 11:25:57.829825142 +0000
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│ │  Device: 259,3	Links: 2
│ │  Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ -Modify: 2022-10-31 11:25:57.829825142 +0000
│ │ +Modify: 2022-10-31 11:25:51.046396023 +0000
│   --- /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07/link
├── +++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/link
│ @@ -1 +1 @@
│ -MJTPWNJJMXPGAGOR4AU5SGV3EU
│ +YY2LS2LHD5FII6IXAHIGIUHWCT
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 26        	Blocks: 8          IO Block: 4096   regular file
│ │  Device: 259,3	Links: 1
│ │  Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ -Modify: 2022-10-31 11:25:57.806491480 +0000
│ │ +Modify: 2022-10-31 11:25:51.023062360 +0000
│   --- /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07/lower
├── +++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/lower
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 57        	Blocks: 8          IO Block: 4096   regular file
│ │  Device: 259,3	Links: 1
│ │  Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ -Modify: 2022-10-31 11:25:57.806491480 +0000
│ │ +Modify: 2022-10-31 11:25:51.023062360 +0000
│   --- /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07/work
├── +++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/work
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│ │  Device: 259,3	Links: 3
│ │  Access: (0700/drwx------)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ +Modify: 2022-10-31 11:25:51.023062360 +0000
│ │ -Modify: 2022-10-31 11:25:57.806491480 +0000
│ │   --- /var/lib/docker/overlay2/b961fc9f522d3e9bd9ab215e1292e5a6a5f461e61913bf47f041d49d7e3c3a07/work/work
│ ├── +++ /var/lib/docker/overlay2/fefa77080b6ef9f2bea5a425761f94d0f955c10768945f1626d211aba298ee34/work/work
│ │ ├── stat {}
│ │ │ @@ -1,8 +1,8 @@
│ │ │  
│ │ │    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│ │ │  Device: 259,3	Links: 2
│ │ │  Access: (0000/d---------)  Uid: (    0/    root)   Gid: (    0/    root)
│ │ │  
│ │ │ -Modify: 2022-10-31 11:25:57.806491480 +0000
│ │ │ +Modify: 2022-10-31 11:25:51.023062360 +0000
│ │ ├── stat {}
│ │ │ @@ -1,8 +1,8 @@
│ │ │  
│ │ │    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│ │ │  Device: 259,3	Links: 2
│ │ │  Access: (0000/d---------)  Uid: (    0/    root)   Gid: (    0/    root)
│ │ │  
│ │ │ +Modify: 2022-10-31 11:25:51.023062360 +0000
│ │ │ -Modify: 2022-10-31 11:25:57.806491480 +0000
│ ├── stat {}
│ │ @@ -1,8 +1,8 @@
│ │  
│ │    Size: 4096      	Blocks: 8          IO Block: 4096   directory
│ │  Device: 259,3	Links: 3
│ │  Access: (0700/drwx------)  Uid: (    0/    root)   Gid: (    0/    root)
│ │  
│ │ -Modify: 2022-10-31 11:25:57.806491480 +0000
│ │ +Modify: 2022-10-31 11:25:51.023062360 +0000

It looks like they only differ in the modification time, which I guess should not happen when the --reproducible flag is passed, right?

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
@leongross leongross changed the title Builds not reproducible Builds not reproducible --reproducible Oct 31, 2022
@leongross leongross changed the title Builds not reproducible --reproducible Problems with --reproducible (modified timestamp) Oct 31, 2022
@Sjd-Risca
Copy link

Unlucky this is an already known issue, since version 1.8 as described here by bug 2005. Into such issue is described also the reason behind the anomalous behavior.

@aaron-prindle aaron-prindle added feature/reproducible-digest has-repro priority/p1 Basic need feature compatibility with docker build. we should be working on this next. priority/p2 High impact feature/bug. Will get a lot of users happy kind/bug Something isn't working labels Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/reproducible-digest has-repro kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next. priority/p2 High impact feature/bug. Will get a lot of users happy
Projects
None yet
Development

No branches or pull requests

3 participants