Add a way to specify a custom graphdriver priority list
during build. This can be done with something like
go build -ldflags "-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper"
As ldflags are already used by the engine build process, and it seems
that only one (last) `-ldflags` argument is taken into account by go,
an envoronment variable `DOCKER_LDFLAGS` is introduced in order to
be able to append some text to `-ldflags`. With this in place,
using the feature becomes
make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary
The idea behind this is, the priority list might be different
for different distros, so vendors are now able to change it
without patching the source code.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
... | ... |
@@ -16,6 +16,13 @@ export DOCKER_GITCOMMIT |
16 | 16 |
# env vars passed through directly to Docker's build scripts |
17 | 17 |
# to allow things like `make KEEPBUNDLE=1 binary` easily |
18 | 18 |
# `project/PACKAGERS.md` have some limited documentation of some of these |
19 |
+# |
|
20 |
+# DOCKER_LDFLAGS can be used to pass additional parameters to -ldflags |
|
21 |
+# option of "go build". For example, a built-in graphdriver priority list |
|
22 |
+# can be changed during build time like this: |
|
23 |
+# |
|
24 |
+# make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary |
|
25 |
+# |
|
19 | 26 |
DOCKER_ENVS := \ |
20 | 27 |
-e DOCKER_CROSSPLATFORMS \ |
21 | 28 |
-e BUILD_APT_MIRROR \ |
... | ... |
@@ -31,6 +38,7 @@ DOCKER_ENVS := \ |
31 | 31 |
-e DOCKER_GITCOMMIT \ |
32 | 32 |
-e DOCKER_GRAPHDRIVER \ |
33 | 33 |
-e DOCKER_INCREMENTAL_BINARY \ |
34 |
+ -e DOCKER_LDFLAGS \ |
|
34 | 35 |
-e DOCKER_PORT \ |
35 | 36 |
-e DOCKER_REMAP_ROOT \ |
36 | 37 |
-e DOCKER_STORAGE_OPTS \ |
... | ... |
@@ -208,7 +208,9 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err |
208 | 208 |
|
209 | 209 |
// Guess for prior driver |
210 | 210 |
driversMap := scanPriorDrivers(config.Root) |
211 |
- for _, name := range priority { |
|
211 |
+ list := strings.Split(priority, ",") |
|
212 |
+ logrus.Debugf("[graphdriver] priority list: %v", list) |
|
213 |
+ for _, name := range list { |
|
212 | 214 |
if name == "vfs" { |
213 | 215 |
// don't use vfs even if there is state present. |
214 | 216 |
continue |
... | ... |
@@ -243,7 +245,7 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err |
243 | 243 |
} |
244 | 244 |
|
245 | 245 |
// Check for priority drivers first |
246 |
- for _, name := range priority { |
|
246 |
+ for _, name := range list { |
|
247 | 247 |
driver, err := getBuiltinDriver(name, config.Root, config.DriverOptions, config.UIDMaps, config.GIDMaps) |
248 | 248 |
if err != nil { |
249 | 249 |
if isDriverNotSupported(err) { |
... | ... |
@@ -7,10 +7,8 @@ import ( |
7 | 7 |
) |
8 | 8 |
|
9 | 9 |
var ( |
10 |
- // Slice of drivers that should be used in an order |
|
11 |
- priority = []string{ |
|
12 |
- "zfs", |
|
13 |
- } |
|
10 |
+ // List of drivers that should be used in an order |
|
11 |
+ priority = "zfs" |
|
14 | 12 |
) |
15 | 13 |
|
16 | 14 |
// Mounted checks if the given path is mounted as the fs type |
... | ... |
@@ -51,16 +51,8 @@ const ( |
51 | 51 |
) |
52 | 52 |
|
53 | 53 |
var ( |
54 |
- // Slice of drivers that should be used in an order |
|
55 |
- priority = []string{ |
|
56 |
- "btrfs", |
|
57 |
- "zfs", |
|
58 |
- "overlay2", |
|
59 |
- "aufs", |
|
60 |
- "overlay", |
|
61 |
- "devicemapper", |
|
62 |
- "vfs", |
|
63 |
- } |
|
54 |
+ // List of drivers that should be used in an order |
|
55 |
+ priority = "btrfs,zfs,overlay2,aufs,overlay,devicemapper,vfs" |
|
64 | 56 |
|
65 | 57 |
// FsNames maps filesystem id to name of the filesystem. |
66 | 58 |
FsNames = map[FsMagic]string{ |
... | ... |
@@ -3,10 +3,8 @@ |
3 | 3 |
package graphdriver |
4 | 4 |
|
5 | 5 |
var ( |
6 |
- // Slice of drivers that should be used in an order |
|
7 |
- priority = []string{ |
|
8 |
- "unsupported", |
|
9 |
- } |
|
6 |
+ // List of drivers that should be used in an order |
|
7 |
+ priority = "unsupported" |
|
10 | 8 |
) |
11 | 9 |
|
12 | 10 |
// GetFSMagic returns the filesystem id given the path. |
... | ... |
@@ -1,10 +1,8 @@ |
1 | 1 |
package graphdriver |
2 | 2 |
|
3 | 3 |
var ( |
4 |
- // Slice of drivers that should be used in order |
|
5 |
- priority = []string{ |
|
6 |
- "windowsfilter", |
|
7 |
- } |
|
4 |
+ // List of drivers that should be used in order |
|
5 |
+ priority = "windowsfilter" |
|
8 | 6 |
) |
9 | 7 |
|
10 | 8 |
// GetFSMagic returns the filesystem id given the path. |