Browse code

Deprecate --graph flag; Replace with --data-root

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Josh Hawn authored on 2016/11/22 15:17:24
Showing 12 changed files
... ...
@@ -21,7 +21,10 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
21 21
 	flags.Var(opts.NewNamedListOptsRef("authorization-plugins", &conf.AuthorizationPlugins, nil), "authorization-plugin", "Authorization plugins to load")
22 22
 	flags.Var(opts.NewNamedListOptsRef("exec-opts", &conf.ExecOptions, nil), "exec-opt", "Runtime execution options")
23 23
 	flags.StringVarP(&conf.Pidfile, "pidfile", "p", defaultPidFile, "Path to use for daemon PID file")
24
-	flags.StringVarP(&conf.Root, "graph", "g", defaultGraph, "Root of the Docker runtime")
24
+	flags.StringVarP(&conf.Root, "graph", "g", defaultDataRoot, "Root of the Docker runtime")
25
+	flags.MarkDeprecated("graph", "Please use --data-root instead")
26
+	flags.StringVar(&conf.Root, "data-root", defaultDataRoot, "Root directory of persistent Docker state")
27
+
25 28
 	flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
26 29
 	flags.MarkDeprecated("restart", "Please use a restart policy on docker run")
27 30
 	flags.StringVarP(&conf.GraphDriver, "storage-driver", "s", "", "Storage driver to use")
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 var (
13 13
 	defaultPidFile  = "/var/run/docker.pid"
14
-	defaultGraph    = "/var/lib/docker"
14
+	defaultDataRoot = "/var/lib/docker"
15 15
 	defaultExecRoot = "/var/run/docker"
16 16
 )
17 17
 
... ...
@@ -9,8 +9,8 @@ import (
9 9
 )
10 10
 
11 11
 var (
12
-	defaultPidFile string
13
-	defaultGraph   = filepath.Join(os.Getenv("programdata"), "docker")
12
+	defaultPidFile  string
13
+	defaultDataRoot = filepath.Join(os.Getenv("programdata"), "docker")
14 14
 )
15 15
 
16 16
 // installConfigFlags adds flags to the pflag.FlagSet to configure the daemon
... ...
@@ -1936,6 +1936,7 @@ _docker_daemon() {
1936 1936
 		--cluster-store-opt
1937 1937
 		--config-file
1938 1938
 		--containerd
1939
+		--data-root
1939 1940
 		--default-gateway
1940 1941
 		--default-gateway-v6
1941 1942
 		--default-shm-size
... ...
@@ -1947,7 +1948,6 @@ _docker_daemon() {
1947 1947
 		--exec-root
1948 1948
 		--fixed-cidr
1949 1949
 		--fixed-cidr-v6
1950
-		--graph -g
1951 1950
 		--group -G
1952 1951
 		--init-path
1953 1952
 		--insecure-registry
... ...
@@ -2016,7 +2016,7 @@ _docker_daemon() {
2016 2016
 			_filedir
2017 2017
 			return
2018 2018
 			;;
2019
-		--exec-root|--graph|-g)
2019
+		--exec-root|--data-root)
2020 2020
 			_filedir -d
2021 2021
 			return
2022 2022
 			;;
... ...
@@ -2605,6 +2605,7 @@ __docker_subcommand() {
2605 2605
                 "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \
2606 2606
                 "($help)--config-file=[Path to daemon configuration file]:Config File:_files" \
2607 2607
                 "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \
2608
+                "($help)--data-root=[Root directory of persisted Docker data]:path:_directories" \
2608 2609
                 "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
2609 2610
                 "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \
2610 2611
                 "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \
... ...
@@ -2620,7 +2621,6 @@ __docker_subcommand() {
2620 2620
                 "($help)--fixed-cidr=[IPv4 subnet for fixed IPs]:IPv4 subnet: " \
2621 2621
                 "($help)--fixed-cidr-v6=[IPv6 subnet for fixed IPs]:IPv6 subnet: " \
2622 2622
                 "($help -G --group)"{-G=,--group=}"[Group for the unix socket]:group:_groups" \
2623
-                "($help -g --graph)"{-g=,--graph=}"[Root of the Docker runtime]:path:_directories" \
2624 2623
                 "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
2625 2624
                 "($help)--icc[Enable inter-container communication]" \
2626 2625
                 "($help)--init[Run an init inside containers to forward signals and reap processes]" \
... ...
@@ -98,7 +98,8 @@ type CommonConfig struct {
98 98
 	Mtu                  int                       `json:"mtu,omitempty"`
99 99
 	Pidfile              string                    `json:"pidfile,omitempty"`
100 100
 	RawLogs              bool                      `json:"raw-logs,omitempty"`
101
-	Root                 string                    `json:"graph,omitempty"`
101
+	RootDeprecated       string                    `json:"graph,omitempty"`
102
+	Root                 string                    `json:"data-root,omitempty"`
102 103
 	SocketGroup          string                    `json:"group,omitempty"`
103 104
 	TrustKeyPath         string                    `json:"-"`
104 105
 	CorsHeaders          string                    `json:"api-cors-header,omitempty"`
... ...
@@ -353,8 +354,21 @@ func getConflictFreeConfiguration(configFile string, flags *pflag.FlagSet) (*Con
353 353
 	}
354 354
 
355 355
 	reader = bytes.NewReader(b)
356
-	err = json.NewDecoder(reader).Decode(&config)
357
-	return &config, err
356
+	if err := json.NewDecoder(reader).Decode(&config); err != nil {
357
+		return nil, err
358
+	}
359
+
360
+	if config.RootDeprecated != "" {
361
+		logrus.Warn(`The "graph" config file option is deprecated. Please use "data-root" instead.`)
362
+
363
+		if config.Root != "" {
364
+			return nil, fmt.Errorf(`cannot specify both "graph" and "data-root" config file options`)
365
+		}
366
+
367
+		config.Root = config.RootDeprecated
368
+	}
369
+
370
+	return &config, nil
358 371
 }
359 372
 
360 373
 // configValuesSet returns the configuration values explicitly set in the file.
... ...
@@ -4,12 +4,6 @@ import (
4 4
 	"github.com/spf13/pflag"
5 5
 )
6 6
 
7
-var (
8
-	defaultPidFile = "/system/volatile/docker/docker.pid"
9
-	defaultGraph   = "/var/lib/docker"
10
-	defaultExec    = "zones"
11
-)
12
-
13 7
 // Config defines the configuration of a docker daemon.
14 8
 // These are the configuration settings that you pass
15 9
 // to the docker daemon when you launch it with say: `docker -d -e lxc`
... ...
@@ -20,6 +20,16 @@ The following list of features are deprecated in Engine.
20 20
 To learn more about Docker Engine's deprecation policy,
21 21
 see [Feature Deprecation Policy](https://docs.docker.com/engine/#feature-deprecation-policy).
22 22
 
23
+### `-g` and `--graph` flags on `dockerd`
24
+
25
+**Deprecated In Release: v1.14.0**
26
+
27
+**Target For Removal In Release: v1.17**
28
+
29
+The `-g` or `--graph` flag for the `dockerd` or `docker daemon` command was
30
+used to indicate the directory in which to store persistent data and resource
31
+configuration and has been replaced with the more descriptive `--data-root`
32
+flag.
23 33
 
24 34
 ### Top-level network properties in NetworkSettings
25 35
 
... ...
@@ -35,6 +35,7 @@ Options:
35 35
       --containerd string                     Path to containerd socket
36 36
       --cpu-rt-period int                     Limit the CPU real-time period in microseconds
37 37
       --cpu-rt-runtime int                    Limit the CPU real-time runtime in microseconds
38
+      --data-root string                      Root directory of persistent Docker state (default "/var/lib/docker")
38 39
   -D, --debug                                 Enable debug mode
39 40
       --default-gateway ip                    Container default gateway IPv4 address
40 41
       --default-gateway-v6 ip                 Container default gateway IPv6 address
... ...
@@ -49,7 +50,6 @@ Options:
49 49
       --experimental                          Enable experimental features
50 50
       --fixed-cidr string                     IPv4 subnet for fixed IPs
51 51
       --fixed-cidr-v6 string                  IPv6 subnet for fixed IPs
52
-  -g, --graph string                          Root of the Docker runtime (default "/var/lib/docker")
53 52
   -G, --group string                          Group for the unix socket (default "docker")
54 53
       --help                                  Print usage
55 54
   -H, --host list                             Daemon socket(s) to connect to (default [])
... ...
@@ -1139,6 +1139,7 @@ This is a full example of the allowed configuration options on Linux:
1139 1139
 ```json
1140 1140
 {
1141 1141
 	"authorization-plugins": [],
1142
+	"data-root": "",
1142 1143
 	"dns": [],
1143 1144
 	"dns-opts": [],
1144 1145
 	"dns-search": [],
... ...
@@ -1153,7 +1154,6 @@ This is a full example of the allowed configuration options on Linux:
1153 1153
 	"log-opts": {},
1154 1154
 	"mtu": 0,
1155 1155
 	"pidfile": "",
1156
-	"graph": "",
1157 1156
 	"cluster-store": "",
1158 1157
 	"cluster-store-opts": {},
1159 1158
 	"cluster-advertise": "",
... ...
@@ -1232,6 +1232,7 @@ This is a full example of the allowed configuration options on Windows:
1232 1232
 ```json
1233 1233
 {
1234 1234
     "authorization-plugins": [],
1235
+    "data-root": "",
1235 1236
     "dns": [],
1236 1237
     "dns-opts": [],
1237 1238
     "dns-search": [],
... ...
@@ -1243,7 +1244,6 @@ This is a full example of the allowed configuration options on Windows:
1243 1243
     "log-driver": "",
1244 1244
     "mtu": 0,
1245 1245
     "pidfile": "",
1246
-    "graph": "",
1247 1246
     "cluster-store": "",
1248 1247
     "cluster-advertise": "",
1249 1248
     "max-concurrent-downloads": 3,
... ...
@@ -1321,7 +1321,7 @@ The following daemon options must be configured for each daemon:
1321 1321
 ```none
1322 1322
 -b, --bridge=                          Attach containers to a network bridge
1323 1323
 --exec-root=/var/run/docker            Root of the Docker execdriver
1324
--g, --graph=/var/lib/docker            Root of the Docker runtime
1324
+--data-root=/var/lib/docker            Root of persisted Docker data
1325 1325
 -p, --pidfile=/var/run/docker.pid      Path to use for daemon PID file
1326 1326
 -H, --host=[]                          Daemon socket(s) to connect to
1327 1327
 --iptables=true                        Enable addition of iptables rules
... ...
@@ -1338,8 +1338,9 @@ It is very important to properly understand the meaning of those options and to
1338 1338
 If you are not using the default, you must create and configure the bridge manually or just set it to 'none': `--bridge=none`
1339 1339
 - `--exec-root` is the path where the container state is stored. The default value is `/var/run/docker`. Specify the path for
1340 1340
 your running daemon here.
1341
-- `--graph` is the path where images are stored. The default value is `/var/lib/docker`. To avoid any conflict with other daemons
1342
-set this parameter separately for each daemon.
1341
+- `--data-root` is the path where persisted data such as images, volumes, and
1342
+cluster state are stored. The default value is `/var/lib/docker`. To avoid any
1343
+conflict with other daemons, set this parameter separately for each daemon.
1343 1344
 - `-p, --pidfile=/var/run/docker.pid` is the path where the process ID of the daemon is stored. Specify the path for your
1344 1345
 pid file here.
1345 1346
 - `--host=[]` specifies where the Docker daemon will listen for client connections. If unspecified, it defaults to `/var/run/docker.sock`.
... ...
@@ -1365,6 +1366,6 @@ $ sudo dockerd \
1365 1365
         --iptables=false \
1366 1366
         --ip-masq=false \
1367 1367
         --bridge=none \
1368
-        --graph=/var/lib/docker-bootstrap \
1368
+        --data-root=/var/lib/docker-bootstrap \
1369 1369
         --exec-root=/var/run/docker-bootstrap
1370 1370
 ```
... ...
@@ -218,7 +218,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
218 218
 	}
219 219
 	args := append(d.GlobalFlags,
220 220
 		"--containerd", "/var/run/docker/libcontainerd/docker-containerd.sock",
221
-		"--graph", d.Root,
221
+		"--data-root", d.Root,
222 222
 		"--exec-root", d.execRoot,
223 223
 		"--pidfile", fmt.Sprintf("%s/docker.pid", d.Folder),
224 224
 		fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
... ...
@@ -1778,7 +1778,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
1778 1778
 	dockerCmd(c, "run", "--privileged", "--rm", "-v", testDir+":/test:shared", "busybox", "sh", "-c", fmt.Sprintf("mkdir -p /test/test-mount && mount -t ext4 -no loop,rw %v /test/test-mount", loopname))
1779 1779
 	defer mount.Unmount(filepath.Join(testDir, "test-mount"))
1780 1780
 
1781
-	s.d.Start(c, "--graph", filepath.Join(testDir, "test-mount"))
1781
+	s.d.Start(c, "--data-root", filepath.Join(testDir, "test-mount"))
1782 1782
 	defer s.d.Stop(c)
1783 1783
 
1784 1784
 	// pull a repository large enough to fill the mount point
... ...
@@ -17,6 +17,7 @@ dockerd - Enable daemon mode
17 17
 [**--cluster-store-opt**[=*map[]*]]
18 18
 [**--config-file**[=*/etc/docker/daemon.json*]]
19 19
 [**--containerd**[=*SOCKET-PATH*]]
20
+[**--data-root**[=*/var/lib/docker*]]
20 21
 [**-D**|**--debug**]
21 22
 [**--default-gateway**[=*DEFAULT-GATEWAY*]]
22 23
 [**--default-gateway-v6**[=*DEFAULT-GATEWAY-V6*]]
... ...
@@ -33,7 +34,6 @@ dockerd - Enable daemon mode
33 33
 [**--fixed-cidr**[=*FIXED-CIDR*]]
34 34
 [**--fixed-cidr-v6**[=*FIXED-CIDR-V6*]]
35 35
 [**-G**|**--group**[=*docker*]]
36
-[**-g**|**--graph**[=*/var/lib/docker*]]
37 36
 [**-H**|**--host**[=*[]*]]
38 37
 [**--help**]
39 38
 [**--icc**[=*true*]]
... ...
@@ -152,6 +152,11 @@ $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-ru
152 152
 **--containerd**=""
153 153
   Path to containerd socket.
154 154
 
155
+**--data-root**=""
156
+  Path to the directory used to store persisted Docker data such as
157
+  configuration for resources, swarm cluster state, and filesystem data for
158
+  images, containers, and local volumes. Default is `/var/lib/docker`.
159
+
155 160
 **-D**, **--debug**=*true*|*false*
156 161
   Enable debug mode. Default is false.
157 162
 
... ...
@@ -204,9 +209,6 @@ $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-ru
204 204
   Group to assign the unix socket specified by -H when running in daemon mode.
205 205
   use '' (the empty string) to disable setting of a group. Default is `docker`.
206 206
 
207
-**-g**, **--graph**=""
208
-  Path to use as the root of the Docker runtime. Default is `/var/lib/docker`.
209
-
210 207
 **-H**, **--host**=[*unix:///var/run/docker.sock*]: tcp://[host:port] to bind or
211 208
 unix://[/path/to/socket] to use.
212 209
   The socket(s) to bind to in daemon mode specified using one or more