Ubuntu timedatectl 在 Docker 容器中失败

标签 ubuntu docker ubuntu-16.04 ntp

我在 Docker 容器(托管在 macOS 上)中运行了 Ubuntu 16.04 LTS。日期/时间相差大约四天。

$ 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

生效日期为 2017 年 5 月 11 日 06:17:13 UTC。

我想解决这个问题(检查 thisthis )但我什至无法运行 timedatectl:

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

我该如何解决这个问题?

最佳答案

回答提出的实际问题(如何在 Docker 容器中运行 timedatectl status 时修复 Failed to create bus connection: No such file or directory):

将以下标志添加到您的 docker run 命令:

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

您需要 --privileged,否则您会收到“查询服务器失败:对等方重置连接”。音量标志似乎适用于 ro

关于Ubuntu timedatectl 在 Docker 容器中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43907925/

相关文章:

python - 无法使用 apache mod WSGI 在 ubuntu 上部署 Django

amazon-web-services - Amazon ECS 中的最小健康百分比和最大百分比是多少

docker - Travis 多架构构建

java - 我可以在哪个文件中更改 java 堆大小?

mysql - 从 MySQL 转储导入到 Clickhouse

docker - 无法在 WSL 上从 Ubuntu 卸载 Docker

ubuntu - 由于 spotify 存储库,sudo-apt get update 失败

bash - 在 shell/bash 脚本中找不到命令

json - download.file 错误不支持的 URL 方案

vagrant - 找不到提供者docker- Vagrant