Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will a docker container auto sync time with its host machine?

Do I need a NTP server inside a docker container to periodically sync the time or will the container re-sync time with its host machine? The docker container time zone is correctly set.

like image 916
vantt Avatar asked Apr 02 '14 02:04

vantt


People also ask

Does Docker automatically update container?

Your containers are now set up to automatically update whenever you push a new Docker image to your image repository, or when an external maintainer updates an image you're watching.

Does container share data with host?

Docker provides two ways for containers to save files on the host system so that the files are persistent even after the container is shut down. These are Docker volumes and bind mounts. This blog will teach you how to share data between a Docker containerized application and the host computer.

Is Docker run synchronous?

Bookmark this question. Show activity on this post. Docker in it's current form places any docker commands into a work queue and executes them one at a time and sequentially (synchronously). This means if you're creating a single threaded API (node.

Can Docker containers communicate with the host?

If you are running more than one container, you can let your containers communicate with each other by attaching them to the same network. Docker creates virtual networks which let your containers talk to each other. In a network, a container has an IP address, and optionally a hostname.


1 Answers

If you are on OSX running boot2docker, see this issue: https://github.com/boot2docker/boot2docker/issues/290

Time synch becomes an issue because the boot2docker host has its time drift while your OS is asleep. Time synch with your docker container cannot be resolved by running your container with -v /etc/localtime:/etc/localtime:ro

Instead, for now, you have to periodically run this on OSX:

/usr/local/bin/boot2docker ssh sudo ntpclient -s -h pool.ntp.org 

Update for users of Kitematic

If you are running Kitematic, which is now the suggested mechanism for getting up and running on Docker in OSX, you will have to periodically run this command:

docker-machine ssh default 'sudo ntpclient -s -h pool.ntp.org' 

Or, for older versions of docker

docker-machine ssh dev 'sudo ntpclient -s -h pool.ntp.org' 

Update for users of new native Docker for OSX

The new Docker Beta does away with VirtualBox and Docker Machine. The latest builds of docker (currently, 1.12.1-beta25 (build: 11807)) seem to have the ability to detect when there has been a time discontinuity and adjust accordingly. Thus, this should no longer be an issue...hooray!!

like image 105
esilver Avatar answered Oct 22 '22 05:10

esilver