mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Enabled docker volume
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
4a2c3733bd
commit
42a46ed1a4
6 changed files with 60 additions and 38 deletions
|
@ -47,6 +47,8 @@ import (
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/trust"
|
"github.com/docker/docker/trust"
|
||||||
|
volumedrivers "github.com/docker/docker/volume/drivers"
|
||||||
|
"github.com/docker/docker/volume/local"
|
||||||
"github.com/docker/libnetwork"
|
"github.com/docker/libnetwork"
|
||||||
"github.com/opencontainers/runc/libcontainer/netlink"
|
"github.com/opencontainers/runc/libcontainer/netlink"
|
||||||
)
|
)
|
||||||
|
@ -1118,3 +1120,12 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig,
|
||||||
// Now do platform-specific verification
|
// Now do platform-specific verification
|
||||||
return verifyPlatformContainerSettings(daemon, hostConfig, config)
|
return verifyPlatformContainerSettings(daemon, hostConfig, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func configureVolumes(config *Config) (*volumeStore, error) {
|
||||||
|
volumesDriver, err := local.New(config.Root)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
volumedrivers.Register(volumesDriver, volumesDriver.Name())
|
||||||
|
return newVolumeStore(volumesDriver.List()), nil
|
||||||
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ import (
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
volumedrivers "github.com/docker/docker/volume/drivers"
|
|
||||||
"github.com/docker/docker/volume/local"
|
|
||||||
"github.com/docker/libnetwork"
|
"github.com/docker/libnetwork"
|
||||||
nwapi "github.com/docker/libnetwork/api"
|
nwapi "github.com/docker/libnetwork/api"
|
||||||
nwconfig "github.com/docker/libnetwork/config"
|
nwconfig "github.com/docker/libnetwork/config"
|
||||||
|
@ -255,15 +253,6 @@ func migrateIfDownlevel(driver graphdriver.Driver, root string) error {
|
||||||
return migrateIfAufs(driver, root)
|
return migrateIfAufs(driver, root)
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureVolumes(config *Config) (*volumeStore, error) {
|
|
||||||
volumesDriver, err := local.New(config.Root)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
volumedrivers.Register(volumesDriver, volumesDriver.Name())
|
|
||||||
return newVolumeStore(volumesDriver.List()), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func configureSysInit(config *Config) (string, error) {
|
func configureSysInit(config *Config) (string, error) {
|
||||||
localCopy := filepath.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", dockerversion.VERSION))
|
localCopy := filepath.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", dockerversion.VERSION))
|
||||||
sysInitPath := utils.DockerInitPath(localCopy)
|
sysInitPath := utils.DockerInitPath(localCopy)
|
||||||
|
|
|
@ -75,11 +75,6 @@ func migrateIfDownlevel(driver graphdriver.Driver, root string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureVolumes(config *Config) (*volumeStore, error) {
|
|
||||||
// Windows does not support volumes at this time
|
|
||||||
return &volumeStore{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func configureSysInit(config *Config) (string, error) {
|
func configureSysInit(config *Config) (string, error) {
|
||||||
// TODO Windows.
|
// TODO Windows.
|
||||||
return os.Getenv("TEMP"), nil
|
return os.Getenv("TEMP"), nil
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/docker/volume"
|
"github.com/docker/docker/volume"
|
||||||
|
@ -23,11 +22,8 @@ const (
|
||||||
volumesPathName = "volumes"
|
volumesPathName = "volumes"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// ErrNotFound is the typed error returned when the requested volume name can't be found
|
||||||
// ErrNotFound is the typed error returned when the requested volume name can't be found
|
var ErrNotFound = errors.New("volume not found")
|
||||||
ErrNotFound = errors.New("volume not found")
|
|
||||||
oldVfsDir = filepath.Join("vfs", "dir")
|
|
||||||
)
|
|
||||||
|
|
||||||
// New instantiates a new Root instance with the provided scope. Scope
|
// New instantiates a new Root instance with the provided scope. Scope
|
||||||
// is the base path that the Root instance uses to store its
|
// is the base path that the Root instance uses to store its
|
||||||
|
@ -173,22 +169,6 @@ func (r *Root) Get(name string) (volume.Volume, error) {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// scopedPath verifies that the path where the volume is located
|
|
||||||
// is under Docker's root and the valid local paths.
|
|
||||||
func (r *Root) scopedPath(realPath string) bool {
|
|
||||||
// Volumes path for Docker version >= 1.7
|
|
||||||
if strings.HasPrefix(realPath, filepath.Join(r.scope, volumesPathName)) && realPath != filepath.Join(r.scope, volumesPathName) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Volumes path for Docker version < 1.7
|
|
||||||
if strings.HasPrefix(realPath, filepath.Join(r.scope, oldVfsDir)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// localVolume implements the Volume interface from the volume package and
|
// localVolume implements the Volume interface from the volume package and
|
||||||
// represents the volumes created by Root.
|
// represents the volumes created by Root.
|
||||||
type localVolume struct {
|
type localVolume struct {
|
||||||
|
|
29
volume/local/local_unix.go
Normal file
29
volume/local/local_unix.go
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// +build linux freebsd
|
||||||
|
|
||||||
|
// Package local provides the default implementation for volumes. It
|
||||||
|
// is used to mount data volume containers and directories local to
|
||||||
|
// the host server.
|
||||||
|
package local
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var oldVfsDir = filepath.Join("vfs", "dir")
|
||||||
|
|
||||||
|
// scopedPath verifies that the path where the volume is located
|
||||||
|
// is under Docker's root and the valid local paths.
|
||||||
|
func (r *Root) scopedPath(realPath string) bool {
|
||||||
|
// Volumes path for Docker version >= 1.7
|
||||||
|
if strings.HasPrefix(realPath, filepath.Join(r.scope, volumesPathName)) && realPath != filepath.Join(r.scope, volumesPathName) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Volumes path for Docker version < 1.7
|
||||||
|
if strings.HasPrefix(realPath, filepath.Join(r.scope, oldVfsDir)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
18
volume/local/local_windows.go
Normal file
18
volume/local/local_windows.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Package local provides the default implementation for volumes. It
|
||||||
|
// is used to mount data volume containers and directories local to
|
||||||
|
// the host server.
|
||||||
|
package local
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// scopedPath verifies that the path where the volume is located
|
||||||
|
// is under Docker's root and the valid local paths.
|
||||||
|
func (r *Root) scopedPath(realPath string) bool {
|
||||||
|
if strings.HasPrefix(realPath, filepath.Join(r.scope, volumesPathName)) && realPath != filepath.Join(r.scope, volumesPathName) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue