Signed-off-by: Stephen Rust <srust@blockbridge.com>
Stephen Rust authored on 2016/01/09 03:19:25... | ... |
@@ -105,7 +105,7 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe |
105 | 105 |
} |
106 | 106 |
}() |
107 | 107 |
|
108 |
- if err := daemon.createContainerPlatformSpecificSettings(container, params.Config, params.HostConfig, img); err != nil { |
|
108 |
+ if err := daemon.createContainerPlatformSpecificSettings(container, params.Config, params.HostConfig); err != nil { |
|
109 | 109 |
return nil, err |
110 | 110 |
} |
111 | 111 |
|
... | ... |
@@ -9,15 +9,13 @@ import ( |
9 | 9 |
"github.com/Sirupsen/logrus" |
10 | 10 |
"github.com/docker/docker/container" |
11 | 11 |
derr "github.com/docker/docker/errors" |
12 |
- "github.com/docker/docker/image" |
|
13 | 12 |
"github.com/docker/docker/pkg/stringid" |
14 |
- "github.com/docker/docker/volume" |
|
15 | 13 |
containertypes "github.com/docker/engine-api/types/container" |
16 | 14 |
"github.com/opencontainers/runc/libcontainer/label" |
17 | 15 |
) |
18 | 16 |
|
19 | 17 |
// createContainerPlatformSpecificSettings performs platform specific container create functionality |
20 |
-func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig, img *image.Image) error { |
|
18 |
+func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error { |
|
21 | 19 |
if err := daemon.Mount(container); err != nil { |
22 | 20 |
return err |
23 | 21 |
} |
... | ... |
@@ -42,17 +40,7 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain |
42 | 42 |
return derr.ErrorCodeMountOverFile.WithArgs(path) |
43 | 43 |
} |
44 | 44 |
|
45 |
- volumeDriver := hostConfig.VolumeDriver |
|
46 |
- if destination != "" && img != nil { |
|
47 |
- if _, ok := img.ContainerConfig.Volumes[destination]; ok { |
|
48 |
- // check for whether bind is not specified and then set to local |
|
49 |
- if _, ok := container.MountPoints[destination]; !ok { |
|
50 |
- volumeDriver = volume.DefaultDriverName |
|
51 |
- } |
|
52 |
- } |
|
53 |
- } |
|
54 |
- |
|
55 |
- v, err := daemon.volumes.CreateWithRef(name, volumeDriver, container.ID, nil) |
|
45 |
+ v, err := daemon.volumes.CreateWithRef(name, hostConfig.VolumeDriver, container.ID, nil) |
|
56 | 46 |
if err != nil { |
57 | 47 |
return err |
58 | 48 |
} |
... | ... |
@@ -4,14 +4,13 @@ import ( |
4 | 4 |
"fmt" |
5 | 5 |
|
6 | 6 |
"github.com/docker/docker/container" |
7 |
- "github.com/docker/docker/image" |
|
8 | 7 |
"github.com/docker/docker/pkg/stringid" |
9 | 8 |
"github.com/docker/docker/volume" |
10 | 9 |
containertypes "github.com/docker/engine-api/types/container" |
11 | 10 |
) |
12 | 11 |
|
13 | 12 |
// createContainerPlatformSpecificSettings performs platform specific container create functionality |
14 |
-func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig, img *image.Image) error { |
|
13 |
+func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error { |
|
15 | 14 |
for spec := range config.Volumes { |
16 | 15 |
|
17 | 16 |
mp, err := volume.ParseMountSpec(spec, hostConfig.VolumeDriver) |
... | ... |
@@ -31,14 +30,6 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain |
31 | 31 |
} |
32 | 32 |
|
33 | 33 |
volumeDriver := hostConfig.VolumeDriver |
34 |
- if mp.Destination != "" && img != nil { |
|
35 |
- if _, ok := img.ContainerConfig.Volumes[mp.Destination]; ok { |
|
36 |
- // check for whether bind is not specified and then set to local |
|
37 |
- if _, ok := container.MountPoints[mp.Destination]; !ok { |
|
38 |
- volumeDriver = volume.DefaultDriverName |
|
39 |
- } |
|
40 |
- } |
|
41 |
- } |
|
42 | 34 |
|
43 | 35 |
// Create the volume in the volume driver. If it doesn't exist, |
44 | 36 |
// a new one will be created. |
... | ... |
@@ -296,33 +296,6 @@ func hostVolumePath(name string) string { |
296 | 296 |
return fmt.Sprintf("/var/lib/docker/volumes/%s", name) |
297 | 297 |
} |
298 | 298 |
|
299 |
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamedCheckBindLocalVolume(c *check.C) { |
|
300 |
- err := s.d.StartWithBusybox() |
|
301 |
- c.Assert(err, checker.IsNil) |
|
302 |
- |
|
303 |
- expected := s.server.URL |
|
304 |
- dockerfile := fmt.Sprintf(`FROM busybox:latest |
|
305 |
- RUN mkdir /nobindthenlocalvol |
|
306 |
- RUN echo %s > /nobindthenlocalvol/test |
|
307 |
- VOLUME ["/nobindthenlocalvol"]`, expected) |
|
308 |
- |
|
309 |
- img := "test-checkbindlocalvolume" |
|
310 |
- |
|
311 |
- _, err = buildImageWithOutInDamon(s.d.sock(), img, dockerfile, true) |
|
312 |
- c.Assert(err, checker.IsNil) |
|
313 |
- |
|
314 |
- out, err := s.d.Cmd("run", "--rm", "--name", "test-data-nobind", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", "test-external-volume-driver", img, "cat", "/nobindthenlocalvol/test") |
|
315 |
- c.Assert(err, checker.IsNil) |
|
316 |
- |
|
317 |
- c.Assert(out, checker.Contains, expected) |
|
318 |
- |
|
319 |
- c.Assert(s.ec.activations, checker.Equals, 1) |
|
320 |
- c.Assert(s.ec.creations, checker.Equals, 1) |
|
321 |
- c.Assert(s.ec.removals, checker.Equals, 1) |
|
322 |
- c.Assert(s.ec.mounts, checker.Equals, 1) |
|
323 |
- c.Assert(s.ec.unmounts, checker.Equals, 1) |
|
324 |
-} |
|
325 |
- |
|
326 | 299 |
// Make sure a request to use a down driver doesn't block other requests |
327 | 300 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *check.C) { |
328 | 301 |
specPath := "/etc/docker/plugins/down-driver.spec" |