docker 的 daemon.json 在哪里? (失踪)

新手上路,请多包涵

来自 文档

Linux 上配置文件的默认位置是 /etc/docker/daemon.json

但是我的新 docker 安装中没有它:

 # docker --version
Docker version 17.03.1-ce, build c6d412e
# ls -la /etc/docker/
total 12
drwx------  2 root root 4096 Apr 28 17:58 .
drwxr-xr-x 96 root root 4096 Apr 28 17:58 ..
-rw-------  1 root root  244 Apr 28 17:58 key.json
# lsb_release -cs
trusty

原文由 astef 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 5.6k
2 个回答

Linux 上的默认配置文件路径是 /etc/docker/daemon.json 如您所说,但默认情况下不存在。您可以自己编写一个并将其他 docker daemon 配置内容放入其中,而不是将这些配置选项传递到命令行中。您甚至不必做 dockerd --config-file /etc/docker/daemon.json 因为这是默认路径,但它对于正在检查系统的其他人来说是非常有用的。

还要确保您在 /etc/docker/daemon.json 中设置的任何配置与传递给命令行 dockerd 的选项不冲突。以供参考:

配置文件中设置的选项不能与通过标志设置的选项冲突。如果选项在文件和标志之间重复,则 docker 守护程序将无法启动,无论它们的值如何。

原文由 huu 发布,翻译遵循 CC BY-SA 3.0 许可协议

如果您已将 Docker 作为安装 Ubuntu 的一部分安装,那么 Docker 将作为 snap 安装。

配置可以在 /var/snap/docker/current/config/daemon.json 中找到。

参考 https://github.com/docker-archive/docker-snap/issues/22#issuecomment-423361607

概括:

 anonymouse64 commented on 21 Sep 2018

Modifying the daemon.json file is now supported in the version of the snap
I have published in the edge channel. The daemon is now hard-coded to read
the config file for it's settings, so you can now edit the daemon.json
located in $SNAP_DATA/config/daemon.json (on Ubuntu for example $SNAP_DATA
is /var/snap/docker/current, it may be different on your distribution) and
then restart docker for the changes to take effect with:

sudo snap restart docker

You may switch the snap to the edge channel to test this by running:

sudo snap refresh docker --edge

The changes in the edge channel should show up in stable in a short while
if you don't wish to use edge.

这现在似乎存在于“稳定”中。我正在使用 Ubunu 20.04,我发现 daemon.json/var/snap/docker/current/config/daemon.json

我将“日志驱动程序”更改为“本地”,重新启动后由 docker 拾取:

 docker info --format '{{.LoggingDriver}}'
json-file
nano /var/snap/docker/current/config/daemon.json
    # added line:  "log-driver":"local",
snap restart docker
docker info --format '{{.LoggingDriver}}'
local

原文由 NZD 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题