I’m building an docker image with a call like this:
load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image"
)
container_image(
name = "image",
base = "@nginx//image",
files = ["nginx.conf"],
symlinks = {
"/etc/nginx/nginx.conf": "/nginx.conf",
},
tars = [":build_tar"],
tags = ["catalog"],
)
As you can see, the image is supposed to contain the content of the tar archive available at target :build_tar
, as well as the nginx.conf
file.
The problem is that all the timestamps of the contents of produced image (both files taken from the tar archive as well as nginx.conf
file) are set to zero (i.e. midnight Jan 1st 1970).
It looks like the container_image
rule is not preserving timestamps. How can I fix this?
2
Answers
Adding
enable_mtime_preservation = True
param tocontainer_image
call fixes the timestamps.A way to fix it would be to take the image you want to base your container off of, deploy it, then copy the files into it while it is running, and finally repack it for deployment.
I understand that is not ideal but from the searching I’ve done, that’s how everyone recommends doing it.
I am just going to add that I do not completely understand what the image is for so I may be completely wrong on how to fix it.