Boot2Docker and Docker container date out of sync

Recently I encountered an issue with my Docker containers having a different date/time to the host machine. Running the following commands would highlight the issue:

$ date
Mon 22 Dec 2014 16:05:53 GMT

$ docker run --rm -i busybox date
Mon Dec 20 09:53:03 UTC 2014

The problem was due to the Boot2Docker virtual machine on OSX. The following command synchronises the time between host and VM machine ensuring that newly launched docker containers have the correct time.
$ boot2docker ssh "date; sudo ntpd -q -p 0.uk.pool.ntp.org; date";

Leave a Reply

Your email address will not be published. Required fields are marked *