How To Fix Time Drift In Docker

Challenge

You have docker running on your machine and after setting your laptop into standby a couple of times the docker time is running behind the local machine time. I noticed this when using portainer (I love that tool so I use it a lot) but when logging in I got the “Your session has expired” message when wanting to login. a docker reboot fixed it but I’ve got more containers running and don’t want to have t reboot all…

This happens on my Mac when working with docker ‘native’:

  • Version 1.13.1-rc1-beta40 (15241)
  • Channel: beta
  • 0d026e19d7

Solution

  • Enter the ‘native’ image of docker and run hwclock -s
1
2
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
hwclock -s
  • leave screen by pressing ctrl+a,d (keep ctrl pressed and then in sequence a,d)

Now you have a way to fix it without having to restart docker. This is a bug though so I hope docker fixes it soon…