3

I want to verify the effects of clock skew on a distributed system and the simplest way for me to do that is using multiple docker containers linked together.

Can I modify the clocks from individual docker containers so that they are decoupled from the host machine?

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
  • see http://stackoverflow.com/questions/22800624/will-docker-container-auto-sync-time-with-the-host-machine – user2915097 Apr 03 '15 at 14:01
  • @user2915097 - thanks for the comment. I read through that question, but found no relevant information except ": the clock of the container is the same as the clock of the host (except that the container cannot change it, except when it's running in --privileged mode)" . Do you have any information on that? – Robert Munteanu Apr 03 '15 at 15:18

2 Answers2

0

I'm not sure that linked answer is entirely appropriate.

The simple fact is that containers are just processes: you can't do anything inside a container that you can't do in a normal subprocess. You can muck about with timezones and such, but they are still referencing the same kernel clock as anything else.

If you really want to play with time skew, you will probably need to investigate some sort of virtualization solution.

larsks
  • 277,717
  • 41
  • 399
  • 399
0

If you want to run a container with a different time, you can launch it with a different timezone, see this extract from https://github.com/docker/docker/issues/3359#issuecomment-32150214

$ docker run --rm busybox date
Thu Mar 20 04:42:02 UTC 2014
$ docker run --rm -v /etc/localtime:/etc/localtime  busybox date
Thu Mar 20 14:42:20 EST 2014
$ FILE=$(mktemp) ; echo $FILE ; echo -e "Europe/Brussels" > $FILE ; docker run --rm -v $FILE:/etc/timezone -v /usr/share/zoneinfo/Europe/Brussels:/etc/localtime busybox date
/tmp/tmp.JwL2A9c50i
Thu Mar 20 05:42:26 CET 2014
Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
user2915097
  • 30,758
  • 6
  • 57
  • 59