2016/12/9


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
一、现状
1、默认没有这个配置文件,手动创建一个即可。
2、我们目前使用过的操作
在“docker深入2-存储驱动之使用devicemapper(direct-lvm)模式”这一节中,我们是这样操作的:
---------------------------------------
调整 daemon.json 的配置:
[root@n33 ~] # cat /etc/docker/daemon.json
{
     "storage-driver" "devicemapper" ,
     "storage-opts" : [
         "dm.thinpooldev=/dev/mapper/docker-thinpool" ,
         "dm.use_deferred_removal=true" ,
         "dm.use_deferred_deletion=true"
     ]
}
---------------------------------------
 
定义了 storage-driver 的值。
然后重启服务:
[root@n33 ~] # systemctl restart docker && systemctl status docker -l
 
这样做的好处:调整配置时,不用去修改 docker.service的参数,通过配置文件来管理,更为清晰合理。
 
 
 
二、探索
1、linux上一个完整的配置示例
{
     "api-cors-header" "" ,
     "authorization-plugins" : [],
     "bip" "" ,
     "bridge" "" ,
     "cgroup-parent" "" ,
     "cluster-store" "" ,
     "cluster-store-opts" : {},
     "cluster-advertise" "" ,
     "debug" true ,
     "default-gateway" "" ,
     "default-gateway-v6" "" ,
     "default-runtime" "runc" ,
     "default-ulimits" : {},
     "disable-legacy-registry" false ,
     "dns" : [],
     "dns-opts" : [],
     "dns-search" : [],
     "exec-opts" : [],
     "exec-root" "" ,
     "fixed-cidr" "" ,
     "fixed-cidr-v6" "" ,
     "graph" "" ,
     "group" "" ,
     "hosts" : [],
     "icc" false ,
     "insecure-registries" : [],
     "ip" "0.0.0.0" ,
     "iptables" false ,
     "ipv6" false ,
     "ip-forward" false ,
     "ip-masq" false ,
     "labels" : [],
     "live-restore" true ,
     "log-driver" "" ,
     "log-level" "" ,
     "log-opts" : {},
     "max-concurrent-downloads" : 3,
     "max-concurrent-uploads" : 5,
     "mtu" : 0,
     "oom-score-adjust" : -500,
     "pidfile" "" ,
     "raw-logs" false ,
     "registry-mirrors" : [],
     "runtimes" : {
         "runc" : {
             "path" "runc"
         },
         "custom" : {
             "path" "/usr/local/bin/my-runc-replacement" ,
             "runtimeArgs" : [
                 "--debug"
             ]
         }
     },
     "selinux-enabled" false ,
     "storage-driver" "" ,
     "storage-opts" : [],
     "swarm-default-advertise-addr" "" ,
     "tls" true ,
     "tlscacert" "" ,
     "tlscert" "" ,
     "tlskey" "" ,
     "tlsverify" true ,
     "userland-proxy" false ,
     "userns-remap" ""
}
 
上述是官网docs提供的一个示例配置,我们可以参考,选择性的配置其中的部分内容。
 
2、如何配置 registry 相关的参数
涉及以下2个参数:
     "insecure-registries" : [],
     "registry-mirrors" : [],
 
配置示例:
[root@n33 ~] # cat /etc/docker/daemon.json
{
     "storage-driver" "devicemapper" ,
     "storage-opts" : [
         "dm.thinpooldev=/dev/mapper/docker-thinpool" ,
         "dm.use_deferred_removal=true" ,
         "dm.use_deferred_deletion=true"
     ],
     "registry-mirrors" : [
         "http://m.hub.test.com"
     ], 
     "insecure-registries" : [
         "hub.test.com"
     ]
}
     
     
 
ZYXW、参考
1、docs
https: //docs .docker.com /engine/reference/commandline/dockerd/ #/linux-configuration-file