Volume binds for windows containers

This commit is contained in:
Michal Wieczorek
2016-06-19 22:56:09 +02:00
parent 3c578fccde
commit ff6a5aa799
3 changed files with 22 additions and 4 deletions

View File

@@ -7,11 +7,20 @@ import (
"fmt"
"os"
"os/user"
"path/filepath"
"strconv"
"golang.org/x/sys/unix"
)
var (
//Path inside container for mounted directory shared across tasks in a task group.
SharedAllocContainerPath = filepath.Join("/", SharedAllocName)
//Path inside container for mounted directory for local storage.
TaskLocalContainerPath = filepath.Join("/", TaskLocal)
)
func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
// Attempt to hardlink.
if err := os.Link(src, dst); err == nil {

View File

@@ -3,6 +3,15 @@ package allocdir
import (
"errors"
"os"
"path/filepath"
)
var (
//Path inside container for mounted directory that is shared across tasks in a task group.
SharedAllocContainerPath = filepath.Join("c:\\", SharedAllocName)
//Path inside container for mounted directory for local storage.
TaskLocalContainerPath = filepath.Join("c:\\", TaskLocal)
)
func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {

View File

@@ -321,8 +321,8 @@ func (d *DockerDriver) containerBinds(alloc *allocdir.AllocDir, task *structs.Ta
return nil, fmt.Errorf("Failed to find task local directory: %v", task.Name)
}
allocDirBind := fmt.Sprintf("%s:/%s", shared, allocdir.SharedAllocName)
taskLocalBind := fmt.Sprintf("%s:/%s", local, allocdir.TaskLocal)
allocDirBind := fmt.Sprintf("%s:%s", shared, allocdir.SharedAllocContainerPath)
taskLocalBind := fmt.Sprintf("%s:%s", local, allocdir.TaskLocalContainerPath)
if selinuxLabel := d.config.Read("docker.volumes.selinuxlabel"); selinuxLabel != "" {
allocDirBind = fmt.Sprintf("%s:%s", allocDirBind, selinuxLabel)
@@ -351,8 +351,8 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task,
}
// Set environment variables.
d.taskEnv.SetAllocDir(filepath.Join("/", allocdir.SharedAllocName))
d.taskEnv.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal))
d.taskEnv.SetAllocDir(allocdir.SharedAllocContainerPath)
d.taskEnv.SetTaskLocalDir(allocdir.TaskLocalContainerPath)
config := &docker.Config{
Image: driverConfig.ImageName,