Ubuntu timedatectl not working in Docker container

I have Ubuntu 16.04 LTS running in a Docker container (hosted on macOS). Date / time is off for about four days.

$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
$ date
Sun May  7 05:57:21 UTC 2017

      

Effective date: 11 May 2017 06:17:13 UTC.

I wanted to fix this (by checking this and this ), but I can't even run timedatectl

:

$ timedatectl status
Failed to create bus connection: No such file or directory

      

How to fix it?

+3


source to share


2 answers


The time shift is caused by the underlying host OS, which for Docker is not macOS, but actually a Linux VM running on macOS. This is due to the latency of macOS (for example, when closing the lid of a MacBook). Apparently it was recently fixed and should be available soon: https://github.com/docker/for-mac/issues/17#issuecomment-300734810



+1


source


To answer the question asked (how to fix Failed to create bus connection: No such file or directory

when running timedatectl status

in a Docker container):

Add the docker run

following flags to the command :



--privileged
--volume /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:ro

      

You need it --privileged

, otherwise you will get the message "Failed to complete the request to the server: connection reset by peer". The volume flag works fine with ro

.

0


source







All Articles