Docker Community Forums

Share and learn in the Docker community.

Docker Time Synchronization Issue

We are using Docker Engine 19.03.12 on a Ubuntu 18.04 Virtual Machine. All our Docker Images use Alpine Linux 3.10.

After a migration of our Ubuntu VM’s host hardware to new hardware, we are getting the following message when building our code within our Docker images: “warning: Clock skew detected. Your build may be incomplete.”. This seems to point to a time synchronization issue between the Docker containers and the Ubuntu VM. The VM’s time is properly synchronized with the host. After noting that our Docker images were using UTC time, we installed the “tzdata” package within our images to force our time zone using the TZ environment however our build keeps failing. We have also tried to completely reinstall Docker however this also did not help Have other users experienced this issue and are there any workarounds to this?

Did you ever checked the date of your source inside the image build?
What if attributes like creation/modify dates are “from the future” from the image build container’s perspective?

Are you sure vm host, vm guest and container share the same timezone?

Hi Metin, thanks for your response!

The modify times of the files causing the clock skew error in the Docker image are the same as those on the Ubuntu host. The time between the VM host, VM guest and container are the same.

One thing to note is that when we launch our Docker image on our PCs, the timezone is set to UTC time which is not our timezone. Despite this, the clock skew error does not appear on our PCs.

As an extra piece of information, the message before the clock skew error is Warning: File ‘/path/to/file’ has modification time 25 s in the future. The files that create this error are generated as part of the build we perform in the container using “make.”

If you are using boot2docker and ntp doesn’t work inside the docker VM (you are behind a proxy which does not forward ntp packets) but your host is time-synced, you can run the following from your host:

docker-machine ssh default “sudo date -u $(date -u +%m%d%H%M%Y)”
This way you are sending your machine’s current time (in UTC timezone) as a string to set the docker VM time using date (again in UTC timezone).

NOTE: in Windows, inside a bash shell (from the msys git), use:

docker-machine.exe ssh default “sudo date -u $(date -u +%m%d%H%M%Y)”

Thank you, lewish95

We resolved our issue this morning. IT had confirmed to us that the physical machine was properly synchronized however, it turns out it was not so the Ubuntu VM had the wrong time.

Thank you all for your time!