Skip to content

Commit a278c97

Browse files
committed
Revert "volume: allow a prefix for all bind mounts"
This reverts commit 1fc7510.
1 parent 884931b commit a278c97

6 files changed

Lines changed: 14 additions & 28 deletions

File tree

contrib/completion/bash/docker

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,6 @@ _docker_daemon() {
18651865
--add-runtime
18661866
--api-cors-header
18671867
--authorization-plugin
1868-
--bind-mount-prefix
18691868
--bip
18701869
--block-registry
18711870
--bridge -b

daemon/config_unix.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type Config struct {
3838
SeccompProfile string `json:"seccomp-profile,omitempty"`
3939
SigCheck bool `json:"signature-verification"`
4040
EnableSecrets bool `json:"enable-secrets"`
41-
BindMountPrefix string `json:"bind-mount-prefix"`
4241
}
4342

4443
// bridgeConfig stores all the bridge driver specific
@@ -94,7 +93,6 @@ func (config *Config) InstallFlags(flags *pflag.FlagSet) {
9493
flags.StringVar(&config.SeccompProfile, "seccomp-profile", "", "Path to seccomp profile")
9594
flags.BoolVar(&config.SigCheck, "signature-verification", true, "Check image's signatures on pull")
9695
flags.BoolVar(&config.EnableSecrets, "enable-secrets", true, "Enable Secrets")
97-
flags.StringVar(&config.BindMountPrefix, "bind-mount-prefix", "", "Specify a prefix to prepend to the source of a bind mount")
9896

9997
config.attachExperimentalFlags(flags)
10098
}

daemon/volumes_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, er
4343
return nil, err
4444
}
4545
rootUID, rootGID := daemon.GetRemappedUIDGID()
46-
path, err := m.Setup(daemon.configStore.BindMountPrefix, c.MountLabel, rootUID, rootGID)
46+
path, err := m.Setup(c.MountLabel, rootUID, rootGID)
4747
if err != nil {
4848
return nil, err
4949
}

docs/reference/commandline/dockerd.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Options:
2525
--add-runtime value Register an additional OCI compatible runtime (default [])
2626
--api-cors-header string Set CORS headers in the Engine API
2727
--authorization-plugin value Authorization plugins to load (default [])
28-
--bind-mount-prefix Specify a prefix to prepend to the source of a bind mount
2928
--bip string Specify network bridge IP
3029
-b, --bridge string Attach containers to a network bridge
3130
--cgroup-parent string Set parent cgroup for all containers

man/dockerd.8.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dockerd - Enable daemon mode
1111
[**--api-cors-header**=[=*API-CORS-HEADER*]]
1212
[**--authorization-plugin**[=*[]*]]
1313
[**-b**|**--bridge**[=*BRIDGE*]]
14-
[**--bind-mount-prefix[=*PREFIX*]]
1514
[**--bip**[=*BIP*]]
1615
[**--block-registry**[=*[]*]]
1716
[**--cgroup-parent**[=*[]*]]
@@ -134,9 +133,6 @@ $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-ru
134133
Attach containers to a pre\-existing network bridge; use 'none' to disable
135134
container networking
136135

137-
**--bind-mount-prefix**=""
138-
Specify a prefix to use for the source of the bind mounts.
139-
140136
**--bip**=""
141137
Use the provided CIDR notation address for the dynamically created bridge
142138
(docker0); Mutually exclusive of \-b

volume/volume.go

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
mounttypes "github.com/docker/docker/api/types/mount"
1111
"github.com/docker/docker/pkg/idtools"
12-
"github.com/docker/docker/pkg/symlink"
1312
"github.com/docker/docker/pkg/stringid"
1413
"github.com/opencontainers/runc/libcontainer/label"
1514
"github.com/pkg/errors"
@@ -125,28 +124,23 @@ type MountPoint struct {
125124

126125
// Setup sets up a mount point by either mounting the volume if it is
127126
// configured, or creating the source directory if supplied.
128-
func (m *MountPoint) Setup(prefix, mountLabel string, rootUID, rootGID int) (path string, err error) {
129-
symlinkRoot := prefix
130-
if symlinkRoot == "" {
131-
symlinkRoot = "/"
132-
}
133-
sourcePath, err := symlink.FollowSymlinkInScope(filepath.Join(prefix, m.Source), symlinkRoot)
134-
if err != nil {
135-
path = ""
136-
err = errors.Wrapf(err, "error evaluating symlink from mount source '%s'", m.Source)
137-
return
138-
}
139-
127+
func (m *MountPoint) Setup(mountLabel string, rootUID, rootGID int) (path string, err error) {
140128
defer func() {
141129
if err == nil {
142130
if label.RelabelNeeded(m.Mode) {
131+
sourcePath, err := filepath.EvalSymlinks(m.Source)
132+
if err != nil {
133+
path = ""
134+
err = errors.Wrapf(err, "error evaluating symlink from mount source '%s'", m.Source)
135+
return
136+
}
143137
err = label.Relabel(sourcePath, mountLabel, label.IsShared(m.Mode))
144138
if err == syscall.ENOTSUP {
145139
err = nil
146140
}
147141
if err != nil {
148142
path = ""
149-
err = errors.Wrapf(err, "error setting label on mount source '%s'", sourcePath)
143+
err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source)
150144
return
151145
}
152146
}
@@ -168,19 +162,19 @@ func (m *MountPoint) Setup(prefix, mountLabel string, rootUID, rootGID int) (pat
168162
if len(m.Source) == 0 {
169163
return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
170164
}
171-
// system.MkdirAll() produces an error if source exists and is a file (not a directory),
165+
// system.MkdirAll() produces an error if m.Source exists and is a file (not a directory),
172166
if m.Type == mounttypes.TypeBind {
173-
// idtools.MkdirAllNewAs() produces an error if source exists and is a file (not a directory)
167+
// idtools.MkdirAllNewAs() produces an error if m.Source exists and is a file (not a directory)
174168
// also, makes sure that if the directory is created, the correct remapped rootUID/rootGID will own it
175-
if err := idtools.MkdirAllNewAs(sourcePath, 0755, rootUID, rootGID); err != nil {
169+
if err := idtools.MkdirAllNewAs(m.Source, 0755, rootUID, rootGID); err != nil {
176170
if perr, ok := err.(*os.PathError); ok {
177171
if perr.Err != syscall.ENOTDIR {
178-
return "", errors.Wrapf(err, "error while creating mount source path '%s'", sourcePath)
172+
return "", errors.Wrapf(err, "error while creating mount source path '%s'", m.Source)
179173
}
180174
}
181175
}
182176
}
183-
return sourcePath, nil
177+
return m.Source, nil
184178
}
185179

186180
// Path returns the path of a volume in a mount point.

0 commit comments

Comments
 (0)