I have a couple of questions around time in a Docker container:
- Does a Docker container (e.g.
ubuntu:16.04
) have the same time as the host machine when it is started? - Will the time be kept in sync, if I don't interfere?
- Will the time of the container be (1) kept in sync with the starting time or (2) kept in sync with the host or (3) be undefined or (4) something else, if I change the time on the host machine?
- If a CRON job within the continer should execute every full hour - is it guaranteed, that it will be executing?
What I tried
For (1), it looks as if it is the case ($
is host and #
is container):
$ docker run -it ubuntu:18.04 bash
# date --iso-8601=s -u
2018-09-11T18:47:04+00:00
$ date --iso-8601=s -u
2018-09-11T18:47:10+00:00
For (3), I tried to change my local time with sudo date 080622432018
, but I'm not sure if it took effect. I'm not sure if the command is wrong or if just some other system reset the time quickly to the correct one.