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

ast*_*tef 29 ubuntu docker ubuntu-14.04

来自docs:

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
Run Code Online (Sandbox Code Playgroud)

huu*_*huu 41

Linux上的默认配置文件路径/etc/docker/daemon.json与您说的相同,但默认情况下不存在.您可以自己编写一个并在其中添加其他docker守护程序配置,而不是将这些配置选项传递到命令行.您甚至不必这样做,dockerd --config-file /etc/docker/daemon.json因为这是默认路径,但是对于正在检查系统的其他人来说明确它是有用的.

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

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

  • 所以,在全新安装docker-ce后没有"daemon.json"是完全正常的,对吗? (6认同)
  • 这是荒谬的.Dockers文档说你必须在该文件中更改一个标志(iptables).这可能是文档问题,也可能是文件丢失时寄存器中的错误. (3认同)
  • 你如何看待当前运行的docker守护进程指向的配置? (3认同)
  • +1 @floatingpurr 对我来说听起来很正常 - 基于 1) 我的安装默认没有它 2) 我认为它背后的想法是使用“发现”方法,docker 发现这个可选文件的存在. 如果没有它,我们肯定知道将使用默认设置。 (2认同)
  • 根据 `dockerd` 文档:Linux 上配置文件的默认位置是 /etc/docker/daemon.json。--config-file 标志可用于指定非默认位置。(参见https://docs.docker.com/engine/reference/commandline/dockerd/) (2认同)

NZD*_*NZD 11

如果您在 Ubuntu 安装过程中安装了 Docker,那么 Docker 将作为快照安装。

该配置可以在 中找到/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.
Run Code Online (Sandbox Code Playgroud)

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

我将“log-driver”更改为“local”,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
Run Code Online (Sandbox Code Playgroud)