I have dockers running on Linode servers. At times, I see that the time is not right on the dockers. Currently I have changed the run script in every docker to include the f
This is what worked for me with a Fedora 20 host. I ran a container using:
docker run -v /etc/localtime:/etc/localtime:ro -i -t mattdm/fedora /bin/bash
Initially /etc/localtime was a soft link to /usr/share/zoneinfo/Asia/Kolkata which Indian Standard Time. Executing date inside the container showed me same time as that on the host. I exited from the shell and stopped the container using docker stop .
Next, I removed this file and made it link to /usr/share/zoneinfo/Singapore for testing purpose. Host time was set to Singapore time zone. And then did docker start . Then accessed its shell again using nsenter and found that time was now set to Singapore time zone.
docker start
docker inspect -f {{.State.Pid}}
nsenter -m -u -i -n -p -t /bin/bash
So the key here is to use -v /etc/localtime:/etc/localtime:ro when you run the container first time. I found it on this link.
Hope it helps.