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

时间:2017-04-28 21:40:03

标签: ubuntu docker ubuntu-14.04

来自docs

  

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

但是我在新鲜的码头安装上没有它:

# 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

4 个答案:

答案 0 :(得分:34)

Linux上的默认配置文件路径是 int current; int[] array = new int[102]; int sum; for(int i = 0; i < array.length; i++){ current = i; sum = 0; while(current != 0){ sum += current % 10; current = current/10; } array[i] = sum+i; } for(int i = 0; i < array.length; i++){ System.out.println("Index " + i + " :" + array[i]); } ,就像你说的那样,但它默认不存在。您可以自己编写一个并在其中添加其他docker守护程序配置,而不是将这些配置选项传递到命令行。您甚至不必执行/etc/docker/daemon.json,因为这是默认路径,但是对于正在检查系统的其他人来说明确它是有用的。

同时确保您在dockerd --config-file /etc/docker/daemon.json中设置的任何配置与传递到命令行唤醒/etc/docker/daemon.json的选项不冲突。供参考:

  

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

答案 1 :(得分:3)

根据@huu 的回答,我在文档中搜索了具体的参考资料。

注意下面加粗的句子。


参考文献 1:来自 Configure the Docker daemon 部分:

<块引用>

Docker 守护进程有两种配置方式:

  • 使用 JSON 配置文件。这是首选选项,因为它 将所有配置保存在一个地方。

  • 启动时使用标志 码头工人。您可以同时使用这两个选项,只要您 不要在标志和 JSON 文件中指定相同的选项。如果 发生这种情况,Docker 守护进程将不会启动并打印错误 留言。

要使用 JSON 文件配置 Docker 守护程序,请在处创建一个文件 /etc/docker/daemon.json 在 Linux 系统上,或 C:\ProgramData\docker\config\daemon.json 在 Windows 上。在 MacOS 上转到 taskbar > Preferences > Daemon > Advanced 中的鲸鱼。


参考文献 2:来自 Enable debugging 部分

<块引用>

有两种方法可以启用调试。推荐的方法是 在 daemon.json 文件中将调试键设置为 true。这个方法有效 适用于每个 Docker 平台。

  1. 编辑 daemon.json 文件,该文件通常位于 /etc/docker/ 中。 您可能需要创建此文件(如果尚未创建) 在 macOS 或 Windows 上,请勿直接编辑文件。反而, 转到首选项/守护程序/高级。

  2. ....

答案 2 :(得分:0)

如果您在安装 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.

这现在似乎存在于“稳定”中。我使用的是 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

答案 3 :(得分:-1)

在Mac上对我来说,它位于/Users/your-username/.docker

相关问题