Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The mtime for folders within a VOLUME is inconsistent with mtime of files within same VOLUME #17018
If you create a container image with some data exposed in a volume, when you run the container, the mtime of folders within the volume is set to when the container was run rather than when the container image was created. I'm not sure if it's a bug or a feature but I think it perhaps violates the Principle of least astonishment? For example, if I created a container 2 weeks ago, I would imagine the mtime of it's folders to be 2 weeks old, not brand new. From some limited testing, I think files work as expected - their mtime is not reset when the container is run. Ideally, the behaviour of the mtime of folders should be consistent with files.
I blogged about this issue here: http://l33t.peopleperhour.com/2015/10/19/docker-file-modified-time-gotcha/
Environment details (AWS, VirtualBox, physical, etc.):
I can reproduce on my laptop without any virtualisation and also on CoreOS stable channel running on AWS.
How reproducible: Easy
Steps to Reproduce:
I would expect the "Modify" time of folders to be the same every time I run the container.
Maybe a real use-case would be useful to explain how this issue is causing us a headache...
We run a website on a cluster of 3 CoreOS machines. When we have a new version of the website the deployment pipeline will build a data container of the PHP code and start a new web-server container on each of the machines in the cluster that uses
This could be a better example (it's a bit shorter):
This shows using
Consistency is a cornerstone of docker - a container run on one server should be identical to another run somewhere else if they are from the same image. This issue breaks that promise as the mtime will not be consistent across different runs.
I get your point @cpuguy83 , that as soon as you use VOLUME, different rules apply. But you know docker more than the average person and I'd wager that most people would expect consistent mtimes. If I could share data between containers without using VOLUME then I would, but there isn't another way. It is the documented way.
@cpuguy83 , here you go:
Docker preserves mtimes of files, but not folders. Here is a single line test that shows the issue:
See that folders have the problem:
After running, compare the 2 Modify times - they are different on each of the container runs.
See that files don't have the same problem: