Firstly, thank you for your efforts on #4057.
I've tried it out using the following (macOS) when building an image directly to a tar file, and it seems to work the way I'd expect:
docker --version
Docker version 26.0.2, build 3c863ff8d3
cat <<EOF >>Dockerfile
FROM dockerhub.cisco.com/docker.io/alpine:3.18.4
ARG SOURCE_DATE_EPOCH # this is the arg for the 'apk', not for docker build
RUN apk add --no-cache curl
RUN echo "abc" > /tmp/file.txt
EOF
docker build --no-cache --build-arg SOURCE_DATE_EPOCH=0 --output type=tar,dest=image1.tar,rewrite-timestamp=true .
docker build --no-cache --build-arg SOURCE_DATE_EPOCH=0 --output type=tar,dest=image2.tar,rewrite-timestamp=true .
docker build --no-cache --output type=tar,dest=image3.tar .
docker build --no-cache --output type=tar,dest=image4.tar .
diff image1.tar image2.tar # expected: 0 (equal), actual: 0 (equal) -- RESULT: PASS
diff image3.tar image4.tar # expected: 1 (not equal), actual: 1 (not equal) -- RESULT: PASS
Now, how do I do the same when building an image with type=docker? I'm doing the below but not getting the expected results:
docker build --no-cache --build-arg SOURCE_DATE_EPOCH=0 --output type=docker,rewrite-timestamp=true -t test_image:1 .
docker build --no-cache --build-arg SOURCE_DATE_EPOCH=0 --output type=docker,rewrite-timestamp=true -t test_image:2 .
docker build --no-cache -t test_image:3 --output type=docker,rewrite-timestamp=true .
docker build --no-cache -t test_image:4 --output type=docker,rewrite-timestamp=true .
docker save test_image:1 -o test_image1.tar
docker save test_image:2 -o test_image2.tar
docker save test_image:3 -o test_image3.tar
docker save test_image:4 -o test_image4.tar
diff image1.tar image2.tar # expected: 0 (equal), actual: 1 (not equal) -- RESULT: FAIL
diff image3.tar image4.tar # expected: 1 (not equal), actual: 1 (not equal) -- RESULT: PASS
Am I using the SOURCE_DATE_EPOCH and the rewrite-timestamp correctly here? I'd expect that test_image:1 and :2 would be identical but that's not true either.
Firstly, thank you for your efforts on #4057.
I've tried it out using the following (macOS) when building an image directly to a tar file, and it seems to work the way I'd expect:
Now, how do I do the same when building an image with type=docker? I'm doing the below but not getting the expected results:
Am I using the
SOURCE_DATE_EPOCHand therewrite-timestampcorrectly here? I'd expect that test_image:1 and :2 would be identical but that's not true either.